//今天学校的周练赛的一道模拟的“水题”,当时就是没有做出来。。。
//哎,自己模拟的能力真的很差啊,完全是被虐的啊。555
//虽然能模拟出遇到左边的括号进入栈中,遇到右括号,全部弹出这一层,
//但就是没有考虑如果两个字母不在一个括号里面,那就跪了
//1
//{ a } { b } a { a } { a } { a x { a b x } } b x
//比如这组。第二个b和倒数第二个b就完全不相关,没有处理好。。。
//最后看了大神飞蛾扑火的博客才恍然大悟,原来如此啊
//继续练吧
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ceil(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define gcd __gcd
#define highBit(x) (1ULL<<(63-__builtin_clzll(x)))
#define popCount __builtin_popcountll
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const long double PI = acos(-1.L);
template<class T> inline T lcm(const T& a, const T& b) { return a/gcd(a, b)*b; }
template<class T> inline T lowBit(const T& x) { return x&-x; }
template<class T> inline T maximize(T& a, const T& b) { return a=a<b?b:a; }
template<class T> inline T minimize(T& a, const T& b) { return a=a<b?a:b; }
template<class T> inline void unify(const T& c) {
c.resize(unique(c.begin(), c.end())-c.begin());
}
const int maxn = 2508;
const int mn = 30;
vector<int> p[mn];//表示a到z出现第i次的时候的level(层数)
int hang[mn][maxn];//记录行的坐标(a到z)
int lie[mn][maxn];//记录列的坐标(a到z)
int n;
char s[60];
int level;掌握当前的层数
void solve(){
for (int i=1;i<=26;i++){
while(p[i].size()&&p[i][p[i].size()-1]>level)(将这一层全部弹出)
p[i].pop_back();
}
}
int main() {
//freopen("G:\\Code\\1.txt","r",stdin);
scanf("%d",&n);
for (int i=1;i<=n;i++)
p[i].clear();
level=1;
getchar();
for (int i=1;i<=n;i++){
gets(s+1);
// printf("%d:",i);
// puts(s+1);
for (int j=1;s[j]!=0;j++){
if (s[j]>='a'&&s[j]<='z'){
int now = s[j]-'a'+1;
if (p[now].size()&&p[now][p[now].size()-1]<=level){//出现的字母比如a在当前的p数组中存在,表示上一层有a
printf("%d:%d: warning: shadowed declaration of %c, the shadowed position is %d:%d\n",i,j,s[j],
hang[now][p[now].size()],lie[now][p[now].size()]);
}
p[now].push_back(level);
hang[now][p[now].size()]=i;
lie[now][p[now].size()]=j;
}else if (s[j]=='{'){
level++;
}else if (s[j]=='}'){
level--;
solve();
}
}
//getchar();
}
return 0;
}