#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T Min(T x, T y) {     return x < y ? x : y;   }   template <class T>   inline T Max(T x, T y) {     return x > y ? x : y;   }   bool MOP1;   long long T, n, res;   long long head[(105)], nxt[(105)], to[(105)], line;   void add(long long x, long long y) {     nxt[++line] = head[x], to[line] = y, head[x] = line;   }   struct node {     string name;     long long lei, X, Y;     long long tot, mx;     long long sz, bo, sp;     long long x() {       if (lei == 2) return sz ? tot + bo * 2 + (sz - 1) * sp : 0;       if (lei == 3) return sz ? mx + bo * 2 : 0;     }     long long y() {       if (lei == 2) return sz ? mx + bo * 2 : 0;       if (lei == 3) return sz ? tot + bo * 2 + (sz - 1) * sp : 0;     }     void add(node now) {       sz++;       if (lei == 2) {         tot += now.X;         mx = Max(mx, now.Y);       } else if (lei == 3) {         tot += now.Y;         mx = Max(mx, now.X);       }     }     bool operator<(const node &a) const { return name < a.name; }   } A[(105)];   long long read(string k) {     long long res = 0;     for (long long i = 0; i < k.size(); i++)       res = (res << 1) + (res << 3) + (k[i] ^ 48);     return res;   }   map<string, long long> mp;   string str;   long long a, b;   bool mark[(105)];   void dfs(long long x) {     mark[x] = 1;     for (long long i = head[x]; i; i = nxt[i]) {       long long y = to[i];       if (!mark[y]) dfs(y), mark[y] = 1;       A[x].add(A[y]);     }     if (A[x].lei != 1) {       A[x].X = A[x].x();       A[x].Y = A[x].y();     }     return;   }   bool MOP2;   signed main() {     scanf( %d , &T);     while (T--) {       cin >> str;       if (str[0] ==  W ) {         getchar();         getline(cin, str,  ( );         mp[str] = ++n;         A[n].lei = 1;         A[n].name = str;         scanf( %d,%d) , &A[n].X, &A[n].Y);       } else if (str[0] ==  H ) {         cin >> str;         mp[str] = ++n;         A[n].name = str;         A[n].lei = 2;       } else if (str[0] ==  V ) {         cin >> str;         mp[str] = ++n;         A[n].name = str;         A[n].lei = 3;       } else {         res = str.find( . );         a = mp[str.substr(0, res)];         if (str[res + 1] ==  s ) {           long long now = str.find( ( ) + 1;           long long tmp = read(str.substr(now, str.size() - now - 1));           if (str[res + 5] ==  b ) {             A[a].bo = tmp;           } else if (str[res + 5] ==  s ) {             A[a].sp = tmp;           }         } else {           b = mp[str.substr(res + 6, str.size() - res - 7)];           add(a, b);         }       }     }     for (long long i = 1; i <= n; i++)       if (!mark[i]) dfs(i);     sort(A + 1, A + 1 + n);     for (long long i = 1; i <= n; i++)       cout << A[i].name <<     << A[i].X <<     << A[i].Y << endl;     return 0;   }   