text: #include<bits/stdc++.h>
  
  using namespace std;
  
  #define pf(x) printf("%d",x)
  #define pfd(x,y) printf("%d %d",x,y)
  #define pfl(x) printf("%ld",x)
  #define pfll(x) printf("%lld",x)
  #define pfllu(x)
  #define nl printf("\n")
  #define cs(x) printf("Case %d: ",x)
  #define csn(x) printf("Case %d:\n",x)
  #define all(x) x.begin(),x.end()
  #define Find(x,n) find(all(x),n)
  #define pi acos(-1.0)
  #define i64 long long
  #define pb(x) push_back(x)
  #define mset(x,v) memset(x,v,sizeof(x))
  #define sc(n) scanf("%d",&n)
  #define scl(n) scanf("%ld",&n)
  #define scll(n) scanf("%lld",&n)
  #define scd(n,m) scanf("%d %d",&n,&m)
  #define scdl(n,m) scanf("%ld %ld",&n,&m)
  #define scdll(n,m) scanf("%lld %lld",&n,&m)
  #define filein freopen("in.txt","r",stdin)
  #define fileout freopen("my.txt","w",stdout)
  #define inf 100000
  #define MAX 50001
  #define MOD 4294967296
  
  bool isUpper(char ch){ return ( ch>='A' && ch<='Z' ) ?  true :  false; }
  bool isLower(char ch){ return ( ch>='a' && ch<='z')  ?  true :  false; }
  bool isLetter(char ch){ return ( ch>='A' && ch<='Z' || ch>='a' && ch<='z') ?  true :  false; }
  bool isDigit(char ch){ return ( ch>='0' && ch<='9') ?  true :  false; }
  char toLower(char ch){ return (isUpper(ch)) ? (ch+32) : ch; }
  char toUpper(char ch){ return (isLower(ch)) ? (ch-32) : ch; }
  
  template<class T>bool isEven(T a){ return (a%2==0);}
  template<class T>T sq(T a){ return (a*a); }
  template<class T>T gcd(T a,T b){ return b==0 ? a : gcd(b,a%b); }
  template<class T>T lcm(T a,T b){ return (a/gcd(a,b))*b; }
  template<class T>bool isPrime(T n){ for(T i=2; i*i<=n; i++){ if(n%i==0) return false; } return true; }
  template<class T>T Pow(T n,T p) { T res=n; for(T i=1;i<p; i++){ res *= n; } return res; }
  template<class T>T Max(T n,T p) { return (n>=p) ? n : p; }
  template<class T>T ABS(T n) { return (n<0) ?  (-n) :  n; }
  
  map<string,string>account_num;
  map<string,vector<string> >all;
  map<string,float>total;
  vector<string>transactions;
  map<string,map<string,float> >record;
  
  bool getrecord(string names){
      if(names[0] == '0' && names[1] == '0'  && names[2]  == '0' ) return false;
      int sz=names.size();
      string num = "",name = "";
      num += names[0];
      num += names[1];
      num += names [2];
      for(int i=3; i<sz; i++) name+=names[i];
      account_num[num] = name;
      return true;
  }
  
  bool geten(string names,float ac){
  
      if(names[0] == '0' && names[1] == '0'  && names[2]  == '0' ) return false;
      int sz=names.size();
      string sequence = "",ac_name = "";
  
      sequence += names[0];
      sequence += names[1];
      sequence += names [2];
  
      ac_name += names[3];
      ac_name += names[4];
      ac_name += names [5];
  
      if(find(transactions.begin(),transactions.end(),sequence) == transactions.end()){
          transactions.push_back(sequence);
      }
      total[sequence] += ac;
      record[sequence][ac_name] = ac;
      all[sequence].push_back(ac_name);
  
      return true;
  }
  
  int main(){
      string entry;
      float amount;
      while( getline(cin,entry)  ){
          if( !getrecord(entry) ) break;
      }
      while( cin >> entry >> amount  ){
          if( !geten(entry,amount) ) break;
      }
      int sz = transactions.size();
      bool nwline = false;
      for(int i=0; i<sz; i++){
          if(total[transactions[i]] != 0){
  
              printf("*** Transaction %s is out of balance ***\n",transactions[i].c_str());
              int ln = all[transactions[i]].size();
              for(int j=0; j<ln; j++){
                  printf("%-3s %-30s %10.2f\n", all[transactions[i]][j].c_str(), account_num[all[transactions[i]][j]].c_str(), record[transactions[i]][all[transactions[i]][j]]/100);
              }
              printf("%-3s %-30s %10.2f\n","999","Out of Balance",(total[transactions[i]]/100)*(-1.0));
              printf("\n");
          }
      }
      return 0;
  }
  
  
  
  
  
  
  
  
  
  