#include <bits/stdc++.h>
using namespace std;
int main(){
cout<<setprecision(2)<<fixed;
char c;
cin>>c;
double initial;
cin>>initial;
map<char,double> mpp;
mpp[c]=initial;
int n;
cin>>n;
for(int i=0;i<n;i++){
char u,v;
cin>>u>>v;
int pt;
cin>>pt;
double balance=mpp[u];
double to_give = double(balance*pt)/(100.00);
mpp[v]+=to_give;
mpp[u]=balance-to_give;
}
for(auto it:mpp){
cout<<it.first<<" will have "<<it.second<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKXsKIAogICAgY291dDw8c2V0cHJlY2lzaW9uKDIpPDxmaXhlZDsKIAogICAgIGNoYXIgYzsKICAgIGNpbj4+YzsKIAogIGRvdWJsZSBpbml0aWFsOwogIGNpbj4+aW5pdGlhbDsKIAogCiAgbWFwPGNoYXIsZG91YmxlPiBtcHA7CiAgbXBwW2NdPWluaXRpYWw7CiAKICBpbnQgbjsKICBjaW4+Pm47CgogCiAgZm9yKGludCBpPTA7aTxuO2krKyl7CiAgICBjaGFyIHUsdjsKICAgIGNpbj4+dT4+djsKICAgIGludCBwdDsKICAgIGNpbj4+cHQ7CgogCiAgICAgZG91YmxlIGJhbGFuY2U9bXBwW3VdOwogICAgIGRvdWJsZSB0b19naXZlID0gZG91YmxlKGJhbGFuY2UqcHQpLygxMDAuMDApOwogICAgbXBwW3ZdKz10b19naXZlOwogICAgbXBwW3VdPWJhbGFuY2UtdG9fZ2l2ZTsKIAogIH0KIAogCiAgZm9yKGF1dG8gaXQ6bXBwKXsKICAgIGNvdXQ8PGl0LmZpcnN0PDwiIHdpbGwgaGF2ZSAiPDxpdC5zZWNvbmQ8PGVuZGw7CiAgfQogCiAgICAgIHJldHVybiAwOwogICAgfQ==