#include using namespace std; template void chmin(T&x,const T &y) { if(x>y)x=y; } template void chmax(T &x,const T &y) { if(x pii; #define rep(i,l,r) for(int i=l;i<=r;++i) #define per(i,r,l) for(int i=r;i>=l;--i) #define rep0(i,l,r) for(int i=l;i='0')x=x*10+c-'0'; return -x; } int x=c-'0'; while(gc>='0')x=x*10+c-'0'; return x; } #undef gc const int N=100+5,M=100+5,inf=1e9; struct Edge { int x,y,w;char c; }; bool operator <(const Edge &e1,const Edge &e2) { return e1.w>e[i].c; } sort(e+1,e+m+1); rep(i,1,m) { int ans=min(solve('R',i),solve('B',i)); printf("%d\n",ans==inf?-1:ans); } } }