QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#23232#3020. Rainbow GraphakifpatelAC ✓38ms3800kbC++1413.7kb2022-03-14 10:24:102022-04-30 02:37:19

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 02:37:19]
  • 评测
  • 测评结果:AC
  • 用时:38ms
  • 内存:3800kb
  • [2022-03-14 10:24:10]
  • 提交

answer

# 0 "r.cpp"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "r.cpp"
# 1 "/home/dooku/programming/cp/amoguslib/bin/../amoguslib.h" 1
       

#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2")
#pragma GCC optimize("O3,unroll-loops")





    #include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;




template<class K, class V, int L=8, bool alloc=true> struct amogus_map{};





const uint64_t __AMOGUSMAP_HASH_C = uint64_t(4e18 * acos(0)) | 71;







template<class K, class V, int L>
struct amogus_map<K,V,L,false> {
    const int __res = L;
    K table[1<<L];
    V value[1<<L];
    char used_arr[1<<(L-3)];
    int __size=0;

    template<class U=V> typename enable_if<! is_empty<U>::value, V&>::type
    operator[](const K &x) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(x)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=x) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=x, ({used_arr[h/8] |= (1<<(h%8));}), __size++, value[h]=V{};
        }
        return value[h];
    }

    bool count(const K&x) const {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(x)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=x) h = (h+1) & ((1<<__res)-1);
        return ((used_arr[h/8]>>(h%8))&1);
    }

    template<class U=V> typename enable_if<! is_empty<U>::value, bool>::type
    insert(const pair<K, V> &p) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(p.first)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=p.first) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=p.first, ({used_arr[h/8] |= (1<<(h%8));}), value[h]=p.second, __size++;
            return true;
        }
        return false;
    }

    template<class U=V> typename enable_if< is_empty<U>::value, bool>::type
    insert(const K &k) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(k)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=k) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=k, ({used_arr[h/8] |= (1<<(h%8));}), __size++;
            return true;
        }
        return false;
    }
    void clear() {memset(used_arr, 0, 1<<(L-3)); __size=0;}
    int size() {return __size;}
};

template<class K, class V, int L>
struct amogus_map<K,V,L,true> {
    int __res; int __size;
    K* table; V* value; char *used_arr;

    amogus_map() : __res(L), __size(0), table(new K[1<<L]), value(new V[1<<L]), used_arr(new char[1<<(L-3)]()) {}
    amogus_map(const amogus_map& m) {
        __res = m.__res; __size=m.__size;
        table = new K[1<<__res]; copy(m.table, m.table+(1<<__res), table);
        value = new V[1<<__res]; copy(m.value, m.value+(1<<__res), value);
        used_arr = new char[1<<(__res-3)]; copy(m.used_arr, m.used_arr+(1<<(__res-3)), used_arr);
    }
    amogus_map& operator=(amogus_map o) {
        __res=o.__res; __size=o.__size;
        swap(table, o.table); swap(value, o.value); swap(used_arr, o.used_arr);
        return *this;
    }

    bool CHKLOADF() {
        if (__size*3 > (1<<__res)) {
            __res++;
            K* ot=table; V* ov=value; char* ou = used_arr;
            table=new K[1<<__res]; value=new V[1<<__res]; used_arr = new char[1<<(__res-3)]();
            for (int i=0; i<(1<<(__res-1)); ++i) {
                if (((ou[i/8]>>(i%8))&1)) {
                    K k = ot[i];
                    int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(k)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=k) h = (h+1) & ((1<<__res)-1);
                    table[h]=k, ({used_arr[h/8] |= (1<<(h%8));}), value[h]=ov[i];
                }
            }
            delete[]ot; delete[] ou; delete[] ov;
            return true;
        }
        return false;
    }

    template<class U=V> typename enable_if<! is_empty<U>::value, V&>::type
    operator[](const K &x) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(x)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=x) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=x, ({used_arr[h/8] |= (1<<(h%8));}), __size++, value[h]=V{};
            if (CHKLOADF()) return (*this)[x];
        }
        return value[h];
    }

    bool count(const K&x) const {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(x)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=x) h = (h+1) & ((1<<__res)-1);
        return ((used_arr[h/8]>>(h%8))&1);
    }

    template<class U=V> typename enable_if<! is_empty<U>::value, bool>::type
    insert(const pair<K, V> &p) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(p.first)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=p.first) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=p.first, ({used_arr[h/8] |= (1<<(h%8));}), value[h]=p.second, __size++;
            CHKLOADF();
            return true;
        }
        return false;
    }

    template<class U=V> typename enable_if< is_empty<U>::value, bool>::type
    insert(const K &k) {
        int h = __builtin_bswap64(__AMOGUSMAP_HASH_C*hash<K>{}(k)) & ((1<<__res)-1); while (((used_arr[h/8]>>(h%8))&1) && table[h]!=k) h = (h+1) & ((1<<__res)-1);
        if (!((used_arr[h/8]>>(h%8))&1)) {
            table[h]=k, ({used_arr[h/8] |= (1<<(h%8));}), __size++;
            CHKLOADF();
            return true;
        }
        return false;
    }

    void clear() {memset(used_arr, 0, 1<<(__res-3)); __size=0;}
    int size() {return __size;}

    ~amogus_map(){delete[] used_arr; delete[] table; delete[] value;};
};

template<class K, class V, int L, bool alloc>
ostream& operator<< (ostream& o, const amogus_map<K,V,L,alloc> &m) {
 o<<'[';
 for (auto a:m) o<<a <<", ";
 return o<<']';
}





template<class K, class V> struct amogus_map_iter {
    ll *used;
    K *table;
    V *value;
    int sz;
    ll block=0;
    int i=-1;

    amogus_map_iter<K, V>& operator++() {
        block = block & (block-1);
        while (block==0 && i<sz-1) {
            ++i;
            block = used[i];
        }
        return *this;
    };
    amogus_map_iter<K,V> operator++(int) {
        amogus_map_iter<K,V> old=*this;
        operator++();
        return old;
    }

    using ITT = pair<const K, V&>;
    template<class U=V> typename enable_if<! is_empty<U>::value, ITT>::type operator*() {
        int j=__builtin_ffsll(block)-1;
        return {table[i*64+j], value[i*64+j]};
    }
    template<class U=V> typename enable_if< is_empty<U>::value, K>::type operator*() {
        int j=__builtin_ffsll(block)-1;
        return table[i*64+j];
    }
    bool operator==(amogus_map_iter<K,V> o) {
        return o.i==i && o.block==block;
    }
    bool operator!=(amogus_map_iter<K,V> o) {
        return o.i!=i || o.block!=block;
    }
};

template<class K, class V, int L, bool alloc>
amogus_map_iter<K,V> begin(const amogus_map<K,V,L,alloc> &m) {
    amogus_map_iter<K,V> r{(ll*)m.used_arr, m.table, m.value, (1<<m.__res)/64};
    return ++r;
}

template<class K, class V, int L, bool alloc>
amogus_map_iter<K,V> end(const amogus_map<K,V,L,alloc> &m) {
    return {nullptr, nullptr, nullptr, (1<<m.__res)/64, 0, (1<<m.__res)/64-1};
}



template<class T, int L=8, bool alloc=true>
using amogus_set = amogus_map<T, tuple<>, L, alloc>;

template<class T, int __NN, T(* f)(T, T)>
struct segtree {
    T t[2 * __NN];
    int n=__NN;
    T id;

    segtree(){} segtree(T idv) {id=idv;}

    void build() {for (int i=n-1; i>0; --i) t[i] = f(t[i<<1], t[i<<1|1]);}

    void modify(int p, T value) {
        for (p+=n, t[p] = value; p>>=1;) t[p] = f(t[p<<1], t[p<<1|1]);
    }
    void incr(int p, T value) {
        for (p+=n, t[p] = f(t[p], value); p>>=1;) t[p] = f(t[p<<1], t[p<<1|1]);
    }

    T query(int l, int r) {
      T resl=id, resr=id;
      for (l += n, r += n; l < r; l>>=1, r>>=1) {
        if (l&1) resl = f(resl, t[l++]);
        if (r&1) resr = f(t[--r], resr);
      }
      return f(resl, resr);
    }


    int lower_bound(int l, int r, T x, bool (*less)(T, T)) {
        vl segs, segsr;
        int r0=r;
        for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
            if (l&1) segs.push_back(l++);
            if (r&1) segsr.push_back(--r);
        }
        segs.insert(segs.end(), segsr.rbegin(), segsr.rend());

        T cur = id;
        for (int i=0; i<segs.size(); ++i) {
            T neow = f(cur, t[segs[i]]);
            if (!less(neow, x)) {
                for (i=segs[i]; i<n; ) {
                    neow = f(cur, t[i<<=1]);
                    if (less(neow, x)) i++, cur=neow;
                }
                return i-n;
            }
            cur = neow;
        }
        return r0;
    }
};



# 1 "/home/dooku/programming/cp/amoguslib/bin/../prime.h" 1
       

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
void prime_seive(ll *prime, const ll n) {
    for (ll i=2; i<n; i++)
        if (prime[i]==0) {
            prime[i] = i;
            for (ll j=i*i;j<n;j+=i) if(!prime[j]) prime[j]=i;
        }
}

vl prime_seive_list(ll *prime, const ll n) {
    vl primes;
    for (ll i=2; i<n; i++)
        if (prime[i]==0) {
            primes.push_back(i);
            prime[i] = i;
            for (ll j=i*i;j<n;j+=i) if(!prime[j]) prime[j]=i;
        }
    return primes;
}
#pragma GCC diagnostic pop
# 281 "/home/dooku/programming/cp/amoguslib/bin/../amoguslib.h" 2

ll inv(ll a, ll b){return 1<a ? b - inv(b%a,a)*b/a : 1;}


ll CRT(const vector<ll> &a, const vector<ll> &n) {
  ll prod = 1;
  for (auto ni:n) prod*=ni;

  ll sm = 0;
  for (int i=0; i<n.size(); i++) {
    ll p = prod/n[i];
    sm += a[i]*inv(p, n[i])*p;
  }
  return sm % prod;
}





template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;




    #ifdef __SIZEOF_INT128__
        typedef __int128 bb;
    #else
        typedef ll bb;
    #endif
# 323 "/home/dooku/programming/cp/amoguslib/bin/../amoguslib.h"
template<class T, class S>
ostream& operator<<(ostream& o, pair<T, S> p) {
 return o<<'('<<p.first<<", "<<p.second<<')';
}

template<template<class, class...> class T, class... A>
typename enable_if<!(is_same<T<A...>, string>() || is_same<T<A...>, complex< tuple_element_t<0, tuple<A...>> >>()), ostream&>::type
operator<< (ostream& o, T<A...> v) {
 o<<'[';
 for (auto a:v) o<<a <<", ";
 return o<<']';
}


template<ll i, class... T>
typename enable_if<i==sizeof...(T)>::type _p(ostream& o, tuple<T...> t) {}

template<ll i, class... T>
typename enable_if<i<sizeof...(T)>::type _p(ostream& o, tuple<T...> t) {
    _p<i+1>(o << get<i>(t)<< ", ", t);
}

template<class... T>
ostream& operator<<(ostream& o, tuple<T...> t) {
    _p<0>(o<<'(', t);
    return o<<')';
}

void _print() {cerr << "]"<<endl;} template <class T, class... second>
void _print(T t, second... v) {cerr<<t; if (sizeof...(v)) cerr << ", "; _print(v...);}
# 2 "r.cpp" 2


constexpr ll M = 1e9+7;

typedef vector<int> vi;

int8_t I[110], x2[110];
typedef pair<int, int> dtype;
dtype dist[110];
pair<int, int> e[110];
char c[110];
int path[110], w[110], ans[110];

int n;
int find(vi &par, int a) {return a==par[a] ? a : par[a] = find(par, par[a]);}
vi find_ccs(const vi &ed, char col, int skip=-1) {
    vi par(n+1); iota(begin(par), end(par), 0);
    for (int i:ed) if (i-skip && (c[i]=='G' || c[i]==col))
        par[find(par, e[i].first)] = find(par, e[i].second);
    for (int i=1; i<=n; ++i) find(par, i);
    return par;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int m; cin>>n>>m;
    memset(ans, -1, sizeof ans);
    for (ll i=0; i<m; ++i) cin>>e[i].first>>e[i].second>>w[i]>>c[i];

    vi RIe;
    int last_size=m+1;
    while (1) {
        int s=0; RIe.clear();
        for (int i=0; i<m; ++i) {
            dist[i]={-1, -1}, x2[i]=0;
            if (!I[i]) RIe.push_back(i), s+=w[i];
        }
        for (int j=RIe.size(); j<last_size; ++j) ans[j] = s;
        last_size=RIe.size();

        vector<pair<int, int>> edges;

        for (int z : RIe) {
            vi pcr = find_ccs(RIe, 'R', z);
            vi pcb = find_ccs(RIe, 'B', z);
            int ncr=0, ncb=0;
            for (int i=1; i<=n; ++i) ncr+=i==pcr[i], ncb+=i==pcb[i];
            for (int y=0; y<m; ++y) if (I[y]) {

                if (ncr==1 || (ncr==2 && c[y]!='B' && pcr[e[y].first]!=pcr[e[y].second])) edges.push_back({y, z});
                if (ncb==1 || (ncb==2 && c[y]!='R' && pcb[e[y].first]!=pcb[e[y].second])) edges.push_back({z, y});
            }
            if (ncr==1) path[z]=-1, dist[z]={(I[z] ? w[z] : -w[z]), 0};
            if (ncb==1) x2[z]=1;
        }

        for (int it=0; it<=m; ++it)
            for (auto ed:edges) {
                auto __p = ed; auto u = __p.first; auto v = __p.second;
                if (~dist[u].second) {
                    dtype nd = {dist[u].first+(I[v] ? w[v] : -w[v]), dist[u].second+1};
                    if (dist[v].second==-1 || dist[v] > nd) dist[v]=nd, path[v]=u;
                }
            }

        int en=-1;
        for (int i=0; i<m; ++i)
            if (~dist[i].second && x2[i] && (en==-1 || dist[en]>dist[i])) en=i;
        if (en==-1) break;

        while (~en) I[en]^=1, en=path[en];
    }
    for (int i=1; i<=m; ++i) cout<<ans[i]<<'\n';
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3672kb

input:

5 8
1 5 1 R
2 1 2 R
5 4 5 R
4 5 3 G
1 3 3 G
4 3 5 G
5 4 1 B
1 2 2 B

output:

-1
-1
-1
-1
15
14
17
22

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 21ms
memory: 3592kb

input:

31 93
11 28 508 B
5 29 329 R
26 27 213 R
23 21 11 B
19 20 373 R
7 14 19 B
11 15 478 B
9 27 737 R
8 30 548 B
14 8 468 R
27 14 989 G
25 25 235 B
18 3 669 R
26 5 254 B
8 6 866 G
26 30 612 R
29 4 658 R
3 11 690 R
29 24 650 R
17 24 986 B
13 19 608 B
10 26 380 B
3 17 998 R
12 16 849 B
23 5 449 B
19 13 302...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18184
17680
17536
17681
17916
18215
18677
19147
19634
20132
20662
21210
21760
22322
22902
23503
24106
24714
25326
25976
26628
27286
27955
28636
29321
30011
307...

result:

ok 93 numbers

Test #3:

score: 0
Accepted
time: 28ms
memory: 3664kb

input:

31 92
23 28 549 G
27 23 834 G
11 15 330 G
21 27 293 B
26 2 799 B
11 21 691 B
26 15 495 B
4 29 846 B
11 18 386 B
10 4 482 G
8 2 702 R
23 15 227 G
5 9 742 G
25 1 125 G
1 2 507 G
24 16 500 G
7 23 905 G
14 9 458 G
22 9 150 R
8 4 241 G
21 30 344 B
20 1 947 G
28 27 282 G
10 15 995 B
23 22 837 B
29 7 215 B...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11566
11086
10729
10730
10752
10813
10955
11167
11382
11608
11849
12094
12387
12731
13083
13436
13822
14225
14681
15138
15600
16082
16577
17082
17589
18096
18604
19112
19638
20191
20749
21341
21941
22552
23199
...

result:

ok 92 numbers

Test #4:

score: 0
Accepted
time: 10ms
memory: 3724kb

input:

31 89
28 24 909 R
2 23 7 R
22 14 221 B
20 8 687 G
13 17 500 B
26 8 208 B
17 12 865 B
24 2 194 R
1 22 590 R
8 28 139 B
29 19 10 B
11 6 611 R
19 10 343 B
20 7 15 R
25 12 962 B
15 4 9 B
14 22 476 R
9 18 289 G
7 20 495 B
5 2 588 B
3 12 817 R
28 2 98 B
22 1 263 R
28 1 543 B
4 26 521 G
18 6 713 B
14 26 28...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19620
19828
20090
20415
20894
21437
21990
22554
23125
23711
24298
24888
25492
26108
26795
27508
28252
29008
29778
30560
31348
32162
329...

result:

ok 89 numbers

Test #5:

score: 0
Accepted
time: 10ms
memory: 3640kb

input:

33 94
31 7 936 R
30 18 194 B
14 20 697 B
8 29 385 R
12 3 509 R
17 27 668 R
19 20 105 R
32 26 781 R
15 12 808 R
31 28 509 R
11 18 713 B
15 10 313 R
17 29 84 B
8 6 134 B
31 7 705 B
27 28 583 B
25 7 228 R
4 6 883 R
20 19 335 R
10 7 658 B
22 23 682 R
17 27 79 B
19 19 138 B
18 7 587 B
32 2 830 B
19 13 95...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
24947
25085
25362
25661
25996
26383
26783
27238
27747
28322
28902
29483
30066
30748
31456
32169
32882
33674
34478
352...

result:

ok 94 numbers

Test #6:

score: 0
Accepted
time: 6ms
memory: 3704kb

input:

31 78
31 16 858 G
29 10 224 R
22 15 648 R
7 31 32 G
18 9 591 R
29 17 73 B
27 30 347 R
3 22 406 R
4 7 223 R
7 17 8 B
14 5 767 G
31 16 61 B
30 18 632 B
21 23 389 B
31 28 951 G
9 4 3 R
1 28 260 G
7 3 69 B
27 12 189 B
29 14 919 R
21 18 753 G
9 26 666 B
11 7 169 B
10 31 886 B
27 8 405 B
19 14 278 R
3 11 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
16414
16352
16381
16442
16711
17089
17508
17931
18369
18841
19372
19904
20474
21080
21712
22348
22995
23643
24309
24977
25656
26354
27054
27825
28606
29398
30236
310...

result:

ok 78 numbers

Test #7:

score: 0
Accepted
time: 24ms
memory: 3740kb

input:

33 90
21 31 44 G
27 31 651 G
31 1 319 R
18 13 125 B
12 28 641 R
32 32 229 G
24 30 689 B
8 3 139 B
8 29 457 G
2 32 807 R
5 33 791 B
21 21 505 G
13 28 27 G
24 14 248 B
13 24 799 R
12 7 274 B
22 32 577 G
32 3 472 G
4 27 664 R
22 12 764 G
9 29 810 B
32 19 738 R
13 26 801 G
27 7 374 G
5 22 405 B
29 12 48...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
14438
13978
13640
13338
13306
13368
13472
13611
13808
14037
14357
14717
15107
15497
15902
16311
16742
17239
17742
18247
18756
19272
19862
20465
21082
21713
22354
22998
23649
24311
24975
25664
26373
...

result:

ok 90 numbers

Test #8:

score: 0
Accepted
time: 38ms
memory: 3648kb

input:

32 99
23 12 413 G
18 9 476 G
31 32 409 R
10 31 590 G
24 5 172 G
7 27 465 G
29 5 78 B
3 3 445 B
7 8 372 R
23 26 310 B
21 4 330 R
15 2 486 G
5 6 562 G
21 29 48 B
2 23 106 G
32 6 133 R
20 14 189 G
31 25 130 R
6 29 690 G
27 9 72 G
26 17 482 R
19 11 170 B
5 8 623 G
6 22 846 B
15 1 72 B
17 12 956 B
12 29 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
8860
8559
8275
8122
8128
8138
8157
8197
8269
8346
8476
8609
8761
8946
9133
9339
9558
9779
10015
10324
10647
10973
11331
11706
12102
12511
12924
13343
13788
14243
14706
15171
15646
16122
16604
17089
17575
...

result:

ok 99 numbers

Test #9:

score: 0
Accepted
time: 30ms
memory: 3740kb

input:

33 95
5 10 997 G
30 21 735 G
11 31 381 R
11 31 7 R
26 18 306 R
33 30 368 R
8 30 200 B
2 14 508 R
16 24 996 R
16 20 7 B
18 28 88 G
5 8 823 B
31 15 794 B
17 32 161 B
14 9 206 R
20 23 354 G
19 30 204 G
7 14 552 B
33 31 456 G
12 17 114 R
4 33 158 G
20 16 57 B
26 22 373 B
29 31 956 R
17 23 293 B
20 14 16...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11535
10880
10618
10359
10234
10232
10289
10450
10611
10773
10965
11186
11412
11653
11959
12277
12604
12958
13323
13691
14072
14456
14862
15293
15725
16172
16643
17130
17620
18112
18608
19116
...

result:

ok 95 numbers

Test #10:

score: 0
Accepted
time: 23ms
memory: 3644kb

input:

35 87
31 25 357 G
31 16 853 G
20 13 744 G
4 23 572 B
35 32 743 G
30 19 691 G
28 13 817 G
34 17 885 G
32 30 435 R
14 23 158 G
26 27 371 B
11 14 207 G
18 27 748 R
24 29 771 G
21 6 916 G
30 26 909 G
18 4 11 G
14 31 801 G
6 30 842 G
25 28 612 G
20 12 403 G
21 12 418 G
29 25 143 G
21 17 279 G
3 2 863 G
1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
11419
11018
11283
11628
11985
12342
12713
13096
13483
13871
14274
14705
15140
15582
16027
16481
16976
17481
17999
18521
19076
19648
20249
20860
21472
22163
22867
23578
24293
25028
25766
26508
27251
279...

result:

ok 87 numbers

Test #11:

score: 0
Accepted
time: 11ms
memory: 3700kb

input:

33 77
11 6 171 B
18 24 25 R
1 3 796 R
25 29 409 G
31 21 911 G
33 8 14 G
30 11 90 G
10 16 985 R
22 13 393 B
29 10 907 B
27 27 986 B
11 1 120 R
23 4 666 G
30 9 207 R
33 26 751 G
1 7 404 G
16 32 694 R
21 14 748 R
20 17 881 B
20 21 849 B
8 31 893 G
8 13 620 B
20 9 10 R
27 25 991 G
4 17 584 G
29 20 827 G...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18415
17672
17196
17032
17107
17272
17479
17776
18109
18467
18842
19317
19795
20293
20803
21316
21835
22368
22942
23524
24144
24831
25568
26320
27114
27910
28732
29559
30405
31254
32109
329...

result:

ok 77 numbers

Test #12:

score: 0
Accepted
time: 18ms
memory: 3716kb

input:

31 91
3 25 619 G
8 15 282 B
18 5 542 R
18 30 859 R
20 25 66 R
9 21 322 B
21 19 557 G
31 15 766 B
19 24 905 G
15 30 493 B
3 22 879 R
13 7 114 B
29 9 863 B
21 16 893 B
17 26 576 B
12 12 761 R
23 19 828 G
12 24 216 B
27 6 180 B
22 21 28 R
12 4 431 B
30 8 751 R
24 15 311 R
24 1 639 B
14 14 543 B
14 22 3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20067
19617
19379
19148
19295
19617
19977
20362
20764
21195
21656
22170
22685
23228
23790
24367
24946
25526
26115
26717
27370
28029
28721
29421
30151
30908
316...

result:

ok 91 numbers

Test #13:

score: 0
Accepted
time: 23ms
memory: 3588kb

input:

35 97
20 14 864 G
20 3 96 R
7 9 967 R
32 3 518 B
18 25 598 R
12 11 279 B
17 7 640 B
3 10 392 B
6 26 557 B
9 24 968 B
19 2 632 G
25 14 879 B
16 8 564 R
13 30 203 R
18 34 812 B
15 20 30 B
7 29 501 B
31 7 612 B
22 23 243 B
19 15 537 B
19 21 296 B
4 17 220 B
5 22 776 B
2 10 992 B
29 12 371 R
17 4 273 B
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18999
18518
18377
18505
18708
18922
19195
19482
19872
20279
20749
21231
21732
22239
22776
23336
23900
24475
25073
25674
26278
26889
27501
28133
287...

result:

ok 97 numbers

Test #14:

score: 0
Accepted
time: 14ms
memory: 3688kb

input:

31 79
28 26 175 R
7 18 907 R
17 10 982 B
3 6 518 R
19 4 319 B
13 14 896 B
29 1 925 G
9 8 847 B
2 4 1000 G
11 12 507 R
24 17 958 R
23 3 701 G
11 23 180 R
31 31 105 B
1 7 647 G
6 30 313 B
17 8 339 G
23 24 438 B
9 1 377 G
17 15 76 B
20 5 809 G
15 13 400 B
15 14 921 B
25 21 698 R
11 15 760 B
2 4 470 G
2...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18936
18328
18020
17870
17930
18006
18087
18192
18350
18556
18773
19053
19339
19674
20112
20655
21203
21767
22333
22917
23564
24265
24982
25715
26475
27255
28102
28977
29873
30780
31689
32610
335...

result:

ok 79 numbers

Test #15:

score: 0
Accepted
time: 14ms
memory: 3688kb

input:

34 76
10 30 1 B
19 20 552 G
18 9 4 G
23 23 7 G
23 16 9 R
31 8 26 G
27 3 5 B
21 31 6 B
21 22 756 R
23 5 109 B
1 21 19 G
22 4 124 G
7 3 690 G
11 30 9 G
12 32 26 B
4 27 62 B
19 11 892 B
7 14 234 G
27 26 1 G
32 33 757 G
4 29 4 R
4 20 803 B
6 27 7 R
16 4 1 B
32 34 1 G
21 25 6 B
16 3 201 G
25 3 10 B
34 9 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5398
4711
4390
4159
4045
4046
4048
4051
4056
4061
4067
4073
4080
4087
4095
4103
4113
4125
4146
4172
4215
4277
4342
4411
4520
4645
4881
5120
5405
5708
6031
6453
7005
7639
8311
9001
9757
10530
11333
1...

result:

ok 76 numbers

Test #16:

score: 0
Accepted
time: 16ms
memory: 3708kb

input:

31 86
8 1 53 B
8 17 111 B
14 16 1 R
30 22 2 R
6 18 1 G
31 7 147 G
15 23 10 R
15 8 2 B
20 3 6 B
12 1 276 G
29 27 1 B
18 29 2 R
8 29 1 B
25 11 51 R
8 11 8 R
12 7 11 G
4 26 4 R
26 14 30 R
17 7 62 R
10 6 65 B
24 31 13 B
28 1 3 G
3 4 7 B
3 21 356 B
22 20 88 B
26 20 4 B
1 12 168 R
27 9 493 B
12 5 2 B
30 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3212
2552
2379
2260
2179
2176
2177
2185
2195
2207
2224
2246
2276
2314
2379
2445
2556
2672
2797
2933
3079
3226
3394
3581
3783
3986
4191
4467
4749
5069
5425
5805
62...

result:

ok 86 numbers

Test #17:

score: 0
Accepted
time: 24ms
memory: 3712kb

input:

32 88
27 15 892 R
29 4 310 R
29 31 769 G
16 17 440 R
9 27 191 G
4 15 514 G
12 18 447 R
5 28 882 R
20 31 757 G
28 28 171 R
20 31 110 G
12 28 515 G
22 9 22 R
29 24 662 R
14 8 291 G
22 15 295 B
30 11 938 G
32 17 168 G
18 5 207 R
29 29 170 G
19 32 781 G
19 9 986 G
7 9 385 G
13 28 732 R
9 13 943 G
2 3 75...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
9861
9570
9388
9408
9465
9633
9803
9974
10156
10351
10558
10783
11070
11380
11698
12051
12469
12909
13356
13808
14273
14746
15227
15731
16245
16788
17335
17914
18528
19156
19791
20452
21114
21817
22527
23257
23...

result:

ok 88 numbers

Test #18:

score: 0
Accepted
time: 18ms
memory: 3716kb

input:

34 83
21 30 683 G
17 22 919 G
9 33 306 R
24 32 580 B
4 32 914 B
2 11 666 R
4 29 536 G
4 6 423 R
16 9 101 G
29 10 415 G
10 3 407 G
19 14 268 G
5 29 742 B
22 14 469 B
10 6 155 B
12 14 399 G
1 24 460 R
15 34 175 R
6 25 308 R
19 4 705 G
34 34 347 G
20 8 409 R
25 31 443 G
15 16 569 G
1 15 680 G
26 12 738...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
12976
12138
11704
11367
11060
10927
10939
11088
11299
11622
11969
12392
12819
13274
13734
14203
14686
15222
15772
16332
16901
17474
18054
18671
19310
19976
20656
21339
22044
22764
23487
24210
24948
256...

result:

ok 83 numbers

Test #19:

score: 0
Accepted
time: 20ms
memory: 3792kb

input:

31 99
5 11 765 B
12 21 601 R
9 31 78 B
11 15 33 B
6 7 80 B
2 18 954 B
2 5 973 R
13 18 372 R
29 8 638 B
8 2 966 B
29 11 531 B
8 25 212 R
22 10 965 R
31 7 22 B
27 27 541 R
5 1 11 B
31 9 457 B
31 29 844 R
17 20 284 R
1 1 798 R
16 4 365 B
20 19 174 B
13 24 774 B
4 28 81 R
4 7 352 B
27 6 912 B
19 20 832 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
23199
23280
23645
24065
24522
24993
25489
26008
26532
27073
27661
28299
28957
29625
30300
30988
31703
32468
33249
34046
348...

result:

ok 99 numbers

Test #20:

score: 0
Accepted
time: 24ms
memory: 3720kb

input:

31 95
20 17 993 R
1 8 698 B
31 4 264 B
9 21 899 B
26 2 126 B
25 7 963 R
30 24 333 B
22 25 422 B
21 5 90 B
31 25 604 B
15 8 824 B
16 7 838 G
24 21 598 R
30 7 620 B
7 2 4 R
20 23 534 R
9 8 164 B
1 24 952 B
7 13 150 R
21 28 639 R
8 15 685 R
26 30 933 R
12 21 571 B
8 12 915 R
13 25 807 B
16 14 747 B
19 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18470
18019
17823
17677
17587
17851
18352
18913
19484
20060
20664
21284
21904
22532
23162
23801
24468
25137
25813
26493
27178
27866
28556
29254
29984
30731
31511
...

result:

ok 95 numbers

Test #21:

score: 0
Accepted
time: 23ms
memory: 3792kb

input:

41 90
39 5 787 B
20 7 853 G
7 30 414 G
16 39 520 G
1 24 944 G
9 10 906 G
13 10 672 G
26 14 506 G
6 1 243 G
30 29 338 G
19 36 675 R
41 3 143 R
29 14 660 G
41 3 42 G
35 29 501 G
14 16 698 G
7 25 462 R
20 34 316 G
23 20 926 G
3 2 520 G
38 14 455 B
19 27 817 G
3 37 656 G
6 8 649 G
33 30 675 G
30 12 568 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
12516
12227
12370
12551
12851
13217
13590
14004
14447
14909
15411
15917
16431
16969
17509
18084
18681
19292
19916
20561
21210
21866
22526
23197
23869
24544
25219
25894
26585
27283
280...

result:

ok 90 numbers

Test #22:

score: 0
Accepted
time: 25ms
memory: 3700kb

input:

32 99
12 27 449 R
30 31 678 B
20 14 897 R
32 30 667 R
5 12 245 R
24 14 996 R
21 1 127 R
28 19 884 B
28 5 108 R
29 25 492 G
20 11 842 B
1 28 571 G
30 1 508 R
20 3 201 B
20 12 966 R
28 29 279 R
31 8 909 R
9 8 400 B
23 26 348 B
5 19 448 R
25 5 852 G
14 13 776 B
19 24 492 G
27 10 447 B
8 30 678 B
17 13 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20449
20271
20182
20206
20239
20415
20652
20955
21357
21774
22210
22658
23136
23630
24125
24633
25218
25841
26465
27120
27778
28440
29107
29780
30454
31131
31809
...

result:

ok 99 numbers

Test #23:

score: 0
Accepted
time: 23ms
memory: 3736kb

input:

31 96
11 29 961 R
9 17 257 B
13 25 772 G
25 17 97 B
4 29 106 B
21 13 508 B
4 27 465 B
30 20 253 B
7 19 274 R
14 29 307 R
6 10 865 B
18 22 628 R
27 4 704 R
2 31 127 G
13 16 152 B
21 29 645 R
25 2 807 R
20 26 478 B
31 16 140 R
13 10 424 G
25 19 37 G
31 3 409 G
19 4 198 G
12 2 448 B
23 5 569 R
31 27 80...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13521
12929
12597
12619
12734
12926
13183
13524
13867
14263
14711
15164
15651
16138
16657
17179
17748
18334
18921
19527
20136
20746
21364
21985
22613
23251
23896
24555
252...

result:

ok 96 numbers

Test #24:

score: 0
Accepted
time: 6ms
memory: 3720kb

input:

33 70
8 2 73 G
30 2 189 R
9 11 613 R
23 18 7 G
24 23 161 G
2 5 440 B
28 13 812 G
21 29 312 R
9 10 991 G
23 18 895 B
11 16 979 G
3 31 686 B
5 5 773 R
4 11 902 G
26 20 862 G
2 31 463 G
30 11 477 G
16 14 541 G
4 12 820 G
29 30 357 G
6 27 867 R
8 18 872 R
11 6 451 R
31 20 246 B
6 7 896 B
11 28 985 G
12 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13919
13461
13370
13389
13473
13615
13767
14047
14340
14791
15247
15710
16187
16665
17152
17765
18436
19122
19808
20564
21337
22115
22935
23802
24674
25569
26468
27370
28308
29269
30234
31208
32187
331...

result:

ok 70 numbers

Test #25:

score: 0
Accepted
time: 26ms
memory: 3752kb

input:

32 96
12 16 681 G
9 5 302 B
7 5 342 B
20 25 680 R
12 13 253 B
26 32 987 G
4 4 879 B
3 32 929 G
6 13 977 R
7 2 161 R
20 15 85 R
21 27 179 G
30 20 98 B
12 9 116 B
26 19 732 R
12 16 744 B
11 13 173 B
21 1 111 R
32 30 570 B
27 25 775 R
7 4 855 G
21 19 432 B
4 9 203 B
30 6 507 B
18 24 77 B
16 28 873 G
32...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18103
17501
17415
17528
17724
17977
18265
18563
18865
19235
19662
20117
20614
21121
21656
22201
22761
23331
23917
24507
25134
25786
26460
27136
27845
28558
29302
30067
...

result:

ok 96 numbers

Test #26:

score: 0
Accepted
time: 27ms
memory: 3648kb

input:

39 97
14 26 927 G
9 36 569 G
36 19 9 B
13 36 797 G
4 30 524 G
8 14 409 G
22 17 348 B
8 28 385 G
9 32 155 B
14 16 758 G
24 20 37 G
33 14 339 G
23 39 545 G
6 12 821 B
15 22 26 B
14 13 36 B
6 16 670 G
32 12 287 G
32 15 122 B
14 20 727 G
33 22 870 B
7 31 29 G
22 14 408 B
32 12 459 B
29 23 367 B
6 13 886...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18302
18311
18337
18373
18427
18500
18622
18747
18902
19065
19243
19437
19670
19910
20165
20426
20701
21007
21350
21698
22065
22453
22861
23291
23732
24182
24641
25204
25813
26430
27054
276...

result:

ok 97 numbers

Test #27:

score: 0
Accepted
time: 19ms
memory: 3644kb

input:

32 94
18 9 559 R
18 23 194 R
21 26 871 R
10 8 36 R
25 20 549 B
5 16 668 B
7 18 917 R
16 3 922 G
5 3 306 B
20 4 918 B
29 3 952 B
20 32 58 G
20 19 99 B
14 11 878 B
11 7 748 B
26 4 648 B
27 10 213 B
19 32 788 B
25 32 281 R
16 7 704 B
15 25 503 R
10 14 319 B
2 23 42 R
5 24 886 R
28 10 234 B
8 1 9 B
23 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20198
19683
19777
20120
20679
21265
21854
22473
23119
23767
24435
25110
25794
26498
27205
27953
28703
29472
30246
31034
31825
32626
33434
34259
...

result:

ok 94 numbers

Test #28:

score: 0
Accepted
time: 22ms
memory: 3716kb

input:

37 92
23 33 137 R
8 31 606 G
20 13 204 B
24 5 704 G
32 33 587 G
24 6 346 G
25 28 950 B
34 6 279 G
16 34 337 R
31 35 890 R
12 19 610 G
35 35 319 R
36 23 99 G
23 8 346 G
10 10 200 G
12 19 922 R
5 5 719 B
1 17 205 G
19 29 81 R
9 19 390 G
16 12 551 G
15 2 560 B
8 13 615 G
11 33 363 B
29 1 259 G
2 8 863 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
17706
16805
16383
16133
15958
15799
15846
15906
16106
16310
16520
16779
17040
17310
17583
17869
18188
18513
18850
19196
19559
19934
20317
20710
21125
21603
22163
22769
23376
23986
24623
...

result:

ok 92 numbers

Test #29:

score: 0
Accepted
time: 14ms
memory: 3724kb

input:

33 92
20 14 954 B
33 8 776 B
6 4 368 G
26 9 843 B
8 16 8 B
3 23 934 R
22 10 654 R
17 23 177 R
19 7 154 R
33 28 910 R
19 21 389 R
11 25 217 G
13 21 459 R
4 13 180 B
25 2 34 R
11 5 868 B
5 10 540 R
29 21 900 B
2 7 309 R
7 12 107 B
1 15 54 R
4 15 387 R
7 4 721 B
10 18 404 B
7 24 517 B
30 13 795 B
13 1 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
22999
23006
23035
23215
23405
23757
24144
24533
24951
25410
25877
26467
27068
27684
28345
29094
29862
30638
31429
32234
33047
338...

result:

ok 92 numbers

Test #30:

score: 0
Accepted
time: 24ms
memory: 3732kb

input:

31 97
23 11 940 R
8 7 368 G
16 27 114 B
6 1 702 R
30 4 20 R
23 28 334 R
21 11 44 B
28 2 112 R
20 13 205 R
20 24 963 R
28 29 743 R
26 6 402 B
12 8 6 G
18 1 550 B
31 30 978 R
31 22 824 B
20 27 577 B
20 20 234 B
3 30 621 G
5 9 28 R
16 1 936 B
27 7 57 R
21 27 630 R
29 10 749 R
14 2 987 B
17 29 771 R
24 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
15907
15944
16178
16512
16859
17215
17583
18000
18523
19106
19696
20303
20924
21553
22183
22860
23539
24241
24971
25702
26445
27194
27950
287...

result:

ok 97 numbers

Test #31:

score: 0
Accepted
time: 12ms
memory: 3800kb

input:

40 97
33 31 649 B
5 17 444 B
5 10 507 B
22 21 265 R
11 10 327 B
31 27 956 R
39 39 492 B
35 10 422 R
5 23 722 R
30 39 619 R
8 19 432 B
25 14 392 B
37 7 104 R
21 37 551 R
17 33 819 R
22 24 163 G
29 24 982 R
35 13 531 B
30 10 531 B
10 6 546 R
30 1 856 G
26 3 802 B
36 1 498 R
29 12 735 G
21 21 738 R
26 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
27222
27144
27206
27471
27766
28075
28467
28911
29403
29910
30428
30952
31483
32090
32725
33401
34131
34869
35633
36400
...

result:

ok 97 numbers

Test #32:

score: 0
Accepted
time: 9ms
memory: 3636kb

input:

34 88
30 23 179 R
33 13 803 B
10 7 108 R
19 9 805 R
29 14 714 R
34 3 615 B
30 30 565 R
25 33 216 R
25 18 23 B
1 2 413 R
22 5 431 G
1 2 302 B
17 3 516 G
32 20 639 B
16 7 665 R
16 21 552 B
33 14 9 B
8 3 899 G
18 2 687 B
34 14 975 B
5 23 370 G
11 16 498 B
23 33 762 B
19 19 677 B
29 26 382 B
24 20 53 B
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
21054
20992
21014
21283
21714
22266
22831
23429
24029
24644
25283
25937
26600
27265
27937
28614
29298
29985
30695
31409
32171
32951
33736
...

result:

ok 88 numbers

Test #33:

score: 0
Accepted
time: 23ms
memory: 3724kb

input:

32 100
31 30 959 R
21 21 916 B
14 4 975 B
25 29 12 B
21 10 855 B
11 16 413 B
31 14 65 B
14 16 766 R
30 11 90 R
16 20 450 B
14 23 331 G
27 8 749 B
30 22 65 B
8 30 450 R
16 17 863 B
16 28 482 R
6 14 796 B
16 16 217 B
23 21 748 B
18 30 19 B
6 26 608 R
10 19 625 R
20 30 729 B
5 12 735 R
5 20 273 R
14 1 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19571
19756
19973
20247
20611
21061
21521
22017
22518
23043
23638
24267
24911
25577
26260
26989
27724
28466
29214
29973
30739
315...

result:

ok 100 numbers

Test #34:

score: 0
Accepted
time: 30ms
memory: 3644kb

input:

32 100
14 26 791 R
20 7 152 R
24 21 711 G
11 26 841 R
20 5 200 R
12 4 612 R
16 8 844 R
14 7 282 B
31 5 922 G
23 1 522 B
1 4 339 R
9 29 126 R
19 5 224 B
20 29 336 G
27 13 212 R
11 14 247 B
16 2 870 B
22 5 46 B
23 13 315 R
1 7 673 R
13 13 849 B
20 13 897 G
26 1 956 R
2 1 305 R
5 21 141 G
2 9 5 R
17 23...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
20083
19874
20010
20164
20352
20552
20759
20971
21185
21457
21762
22077
22416
22763
23147
23552
23988
24495
25005
25535
26080
26629
27211
27794
28399
290...

result:

ok 100 numbers

Test #35:

score: 0
Accepted
time: 25ms
memory: 3728kb

input:

31 100
23 31 992 R
21 15 871 R
20 31 894 B
14 23 455 R
20 20 530 R
17 24 825 R
19 28 641 R
9 4 735 B
31 10 19 B
14 14 657 R
26 18 732 B
23 26 984 B
14 8 686 B
14 16 204 B
26 5 115 B
26 22 138 R
30 16 167 G
16 23 373 R
24 10 564 B
6 6 634 R
26 1 321 B
21 13 204 R
18 25 29 R
23 12 739 B
7 31 300 R
29 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
14764
14692
14779
14932
15134
15477
15825
16194
16565
16939
17320
17722
18138
18555
18984
19439
19929
20458
20988
21523
22063
22610
23161
23724
24288
...

result:

ok 100 numbers

Test #36:

score: 0
Accepted
time: 24ms
memory: 3648kb

input:

31 100
19 29 96 R
2 27 993 B
20 21 653 R
15 30 190 B
29 27 338 B
26 31 569 R
12 14 701 B
9 5 995 R
28 10 901 R
14 31 331 R
19 25 228 R
18 16 503 R
31 25 335 G
22 26 769 R
7 28 407 B
26 20 714 R
12 4 16 G
4 7 411 R
31 22 864 B
19 30 383 B
15 15 146 G
4 3 573 G
21 29 435 B
14 26 433 B
29 19 834 B
31 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
17970
17422
17338
17484
17645
17838
18034
18232
18445
18670
19046
19424
19807
20206
20672
21189
21754
22331
22956
23590
24234
24885
25538
26204
26900
...

result:

ok 100 numbers

Test #37:

score: 0
Accepted
time: 29ms
memory: 3796kb

input:

32 100
19 17 436 B
12 16 760 G
18 6 799 R
8 29 575 B
8 24 483 G
21 5 625 R
24 10 896 B
13 29 9 G
9 12 854 R
27 13 439 B
30 32 638 R
24 10 124 B
30 5 938 R
21 9 231 B
2 18 998 R
1 8 850 R
28 29 791 R
3 16 435 B
10 8 235 B
8 24 264 R
28 25 295 B
31 17 743 B
8 6 76 B
5 1 217 B
26 19 580 B
17 23 223 R
2...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19427
18742
18599
18622
18689
18813
19144
19485
19849
20284
20747
21230
21773
22327
22902
23480
24060
24641
25223
25813
26411
27021
27632
28249
28957
...

result:

ok 100 numbers

Test #38:

score: 0
Accepted
time: 33ms
memory: 3704kb

input:

34 100
19 25 132 G
21 27 243 G
32 12 721 B
3 1 187 R
34 13 170 R
11 16 332 G
32 21 222 B
32 32 572 B
24 30 4 G
17 11 494 B
29 24 270 B
19 27 778 R
28 14 197 R
3 16 693 G
16 20 871 G
33 25 215 G
16 29 891 B
2 21 971 B
14 2 544 B
10 19 413 G
9 23 639 G
23 4 480 B
4 22 637 B
6 7 769 R
15 10 242 B
21 30...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
15310
14773
14532
14368
14247
14248
14437
14640
14852
15074
15316
15586
15856
16181
16525
16886
17249
17638
18083
18543
19005
19470
19955
20449
20948
21458
21981
22520
23064
23636
...

result:

ok 100 numbers

Test #39:

score: 0
Accepted
time: 26ms
memory: 3652kb

input:

35 100
32 6 862 R
31 18 894 B
11 26 878 R
4 21 440 B
6 35 380 B
11 16 496 B
22 15 833 G
2 11 721 G
30 19 640 R
16 35 97 R
14 9 548 B
24 9 915 G
29 21 194 B
23 30 637 R
12 28 438 R
32 23 283 B
23 10 662 B
25 17 52 R
26 23 64 R
35 4 466 B
3 16 60 R
14 22 889 R
15 12 221 R
9 2 387 R
29 27 785 R
21 15 5...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
17284
16828
16472
16371
16352
16445
16587
16732
17049
17371
17725
18125
18535
18970
19436
19927
20423
20924
21448
22004
22565
23170
23810
24463
25117
...

result:

ok 100 numbers

Test #40:

score: 0
Accepted
time: 24ms
memory: 3596kb

input:

31 100
29 12 849 R
22 3 276 R
24 13 829 B
28 1 852 B
29 15 292 R
18 23 961 R
24 31 163 B
4 18 398 B
3 27 352 R
5 21 588 B
20 22 65 B
6 10 459 R
24 7 296 R
3 10 729 R
4 25 359 B
7 14 152 G
5 5 912 B
29 13 103 B
22 12 319 B
30 9 667 R
9 9 116 R
17 19 870 B
21 24 525 R
20 3 648 R
29 10 673 B
16 3 856 B...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
21304
21372
21488
21605
21998
22446
22898
23390
23886
24414
24988
25583
26202
26825
27448
28096
28763
29434
30107
30784
31469
32180
...

result:

ok 100 numbers

Test #41:

score: 0
Accepted
time: 27ms
memory: 3652kb

input:

31 100
29 2 500 B
27 20 584 R
25 2 643 R
1 12 648 B
21 23 857 G
19 21 849 R
10 24 673 B
23 14 166 B
6 30 555 G
7 3 87 B
8 25 878 R
11 21 658 R
22 27 108 B
6 25 622 B
2 11 550 B
28 1 718 R
24 12 906 B
2 13 943 B
18 18 587 B
19 10 427 B
17 19 611 G
25 12 553 R
21 31 462 R
26 25 51 B
5 27 772 B
27 29 8...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19720
19251
19109
19010
19188
19432
19737
20095
20477
20886
21313
21775
22255
22746
23246
23772
24304
24837
25382
25929
26479
27051
27638
28241
28863
29511
30160
30833
...

result:

ok 100 numbers

Test #42:

score: 0
Accepted
time: 25ms
memory: 3640kb

input:

33 100
6 17 67 R
15 7 463 R
22 18 989 G
24 3 367 B
18 13 561 B
32 15 851 R
30 26 513 G
25 33 22 B
22 33 331 G
32 8 75 G
31 15 333 R
10 23 451 R
26 3 664 B
12 28 294 R
18 19 162 R
30 7 324 B
10 12 120 R
20 22 870 R
31 21 531 B
2 14 825 R
17 18 913 B
32 2 17 R
32 1 596 B
19 12 232 B
4 15 162 B
9 32 72...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18921
18229
17849
17590
17559
17587
17674
17840
18094
18358
18675
19008
19369
19736
20113
20502
20930
21377
21891
22408
22938
23469
24030
24607
25261
259...

result:

ok 100 numbers

Test #43:

score: 0
Accepted
time: 30ms
memory: 3752kb

input:

47 100
35 23 862 G
10 46 561 R
21 44 859 G
1 38 298 R
23 30 743 G
14 22 914 G
15 34 866 R
37 28 784 R
1 36 755 G
31 2 982 G
35 7 282 G
28 11 44 G
9 18 422 R
28 37 570 G
26 17 410 R
39 14 56 G
45 44 203 R
23 27 704 G
25 5 15 G
14 18 343 G
13 23 45 R
27 13 552 R
13 37 675 R
19 19 916 R
1 16 129 G
45 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18675
18261
17928
17973
18101
18241
18400
18603
18806
19054
19312
19577
19875
20290
20712
21153
21604
22062
22582
23134
23695
24265
24840
25441
26052
26680
27315
279...

result:

ok 100 numbers

Test #44:

score: 0
Accepted
time: 27ms
memory: 3652kb

input:

42 100
28 28 279 B
22 27 913 R
12 6 220 G
37 22 999 B
32 17 931 B
34 14 760 B
25 7 676 G
34 40 5 G
18 18 606 G
25 21 876 R
23 34 662 G
11 34 882 G
35 26 149 R
37 18 922 G
41 18 901 G
17 41 236 R
7 34 780 G
42 1 684 R
1 29 560 G
37 34 757 B
34 40 164 R
19 19 373 R
10 24 203 G
42 8 937 G
1 10 43 G
37 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18390
17768
17329
16994
16783
16604
16617
16685
16849
17085
17358
17637
17979
18352
18750
19152
19591
20042
20501
20967
21443
21929
22479
23077
23683
24339
250...

result:

ok 100 numbers

Test #45:

score: 0
Accepted
time: 22ms
memory: 3700kb

input:

42 100
5 34 239 B
31 7 55 G
21 18 154 G
36 7 370 B
15 10 557 R
9 1 771 G
31 27 248 B
38 4 965 B
14 31 446 R
6 24 818 R
10 16 506 B
24 23 436 G
37 24 827 G
9 30 852 G
25 15 649 B
34 19 456 G
38 5 715 R
20 16 296 G
11 1 581 B
35 13 272 G
9 35 61 R
32 31 398 B
23 10 190 B
33 21 467 R
22 37 265 R
22 27 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
22057
21430
20958
20622
20546
20583
20677
20782
21021
21378
21775
22240
22726
23235
23769
24326
24904
25538
26175
26822
27471
28126
28798
29494
30202
309...

result:

ok 100 numbers

Test #46:

score: 0
Accepted
time: 26ms
memory: 3644kb

input:

43 100
7 2 698 G
20 16 704 G
23 23 342 G
21 36 851 G
6 28 760 R
7 16 989 B
27 37 584 R
28 43 463 G
39 37 178 G
30 22 481 R
30 6 950 R
35 1 270 G
37 11 15 R
34 17 456 G
24 22 797 R
26 28 939 B
42 16 851 G
27 4 920 R
25 22 312 R
7 40 972 R
3 28 137 G
12 42 114 R
16 40 381 G
1 9 237 B
1 9 688 R
37 28 3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18659
18318
18213
18261
18343
18494
18684
18956
19248
19557
19871
20204
20546
20945
21392
21873
22436
23016
23600
24189
24782
25402
26030
26661
27300
27947
28635
29355
...

result:

ok 100 numbers

Test #47:

score: 0
Accepted
time: 27ms
memory: 3788kb

input:

42 100
18 35 294 G
18 13 491 G
12 31 793 R
19 11 215 B
42 41 12 G
20 4 914 G
37 41 467 G
34 26 964 G
22 16 246 G
2 15 39 G
15 15 258 R
28 11 652 R
39 24 556 R
8 8 190 R
27 38 209 R
10 19 400 G
18 15 856 R
41 42 15 G
39 24 911 G
23 31 531 G
32 14 738 G
3 5 829 R
3 38 147 G
17 22 702 G
27 6 758 B
4 30...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13267
12939
12954
12982
13087
13254
13444
13639
13897
14169
14458
14779
15104
15505
15928
16404
16880
17371
17885
18416
18970
19526
20088
20668
21258
21852
22499
23151
238...

result:

ok 100 numbers

Test #48:

score: 0
Accepted
time: 16ms
memory: 3592kb

input:

45 100
21 4 157 R
24 16 884 R
5 44 868 B
14 14 550 G
31 26 823 B
16 9 315 B
27 9 650 R
3 37 893 G
33 5 269 G
20 28 723 R
25 33 299 R
37 29 602 G
43 15 232 R
6 3 985 R
24 13 151 B
36 26 577 G
44 18 659 B
8 40 435 G
18 10 264 R
20 40 59 G
44 33 989 B
28 38 281 B
1 2 7 B
22 12 869 B
6 35 937 G
27 29 36...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
24276
24221
24245
24398
24555
24819
25096
25395
25716
26104
26506
26918
27394
27920
28470
29037
29628
30278
30939
31606
32281
...

result:

ok 100 numbers

Test #49:

score: 0
Accepted
time: 31ms
memory: 3660kb

input:

43 100
3 11 832 G
34 32 694 R
42 43 81 G
3 8 952 G
23 25 135 B
5 34 410 G
2 1 877 G
41 10 717 B
6 25 167 G
1 33 259 B
18 36 833 B
27 34 883 G
38 39 270 B
9 11 802 R
38 19 169 R
28 9 252 B
16 21 942 R
30 21 327 G
15 33 863 G
34 39 755 B
17 30 535 B
17 14 533 R
6 31 921 B
22 36 676 G
10 21 750 G
14 24...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
19001
18628
18584
18619
18664
18786
18921
19066
19233
19408
19597
19789
20048
20309
20579
20875
21329
21819
22325
22857
23390
23925
24476
25031
25622
26220
26830
27463
28129
...

result:

ok 100 numbers

Test #50:

score: 0
Accepted
time: 30ms
memory: 3652kb

input:

42 100
31 11 451 R
26 3 503 B
42 6 914 R
27 36 930 B
36 36 873 B
20 38 742 G
34 39 938 B
28 39 787 G
27 41 141 G
34 10 123 R
4 13 913 R
15 7 650 G
19 23 255 G
10 20 70 B
36 24 523 B
16 24 296 R
27 9 236 G
2 15 55 R
21 4 989 B
11 33 77 G
23 6 784 G
35 21 673 G
41 10 626 G
19 41 482 G
11 37 985 R
20 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
18783
18283
17922
17704
17516
17342
17304
17312
17387
17562
17828
18114
18410
18714
19145
19608
20083
20561
21064
21587
22134
22697
23276
23867
24463
25068
25679
26305
269...

result:

ok 100 numbers

Test #51:

score: 0
Accepted
time: 32ms
memory: 3656kb

input:

42 100
35 13 612 R
10 32 241 G
5 5 950 R
24 30 850 B
5 35 641 R
16 26 722 G
21 30 380 G
32 14 56 G
40 29 94 G
7 18 85 G
11 1 10 R
31 39 289 G
18 33 872 G
28 19 773 G
20 8 11 R
17 34 640 R
8 42 402 G
13 35 838 G
14 12 947 B
1 36 237 R
11 9 355 R
10 41 947 G
42 24 815 R
24 19 550 B
30 5 895 R
26 30 33...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
14443
13893
13564
13307
13056
13052
13068
13189
13386
13599
13829
14066
14318
14645
14984
15339
15740
16167
16651
17197
17747
18323
18906
19495
20098
20701
21313
21937
22567
232...

result:

ok 100 numbers

Test #52:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

94 94
56 1 946 G
8 66 109 G
74 37 301 G
72 59 799 G
92 46 811 G
72 9 132 G
75 62 610 G
88 65 985 G
71 77 624 G
9 23 585 G
36 88 94 G
47 60 832 G
10 17 114 G
75 13 379 G
18 60 840 G
55 84 350 G
78 19 992 G
69 20 874 G
49 42 846 G
73 81 320 G
14 46 535 G
57 37 300 G
39 42 105 G
15 91 592 G
35 46 587 G...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
45756
46621

result:

ok 94 numbers

Test #53:

score: 0
Accepted
time: 3ms
memory: 3596kb

input:

81 81
79 28 92 G
58 39 293 R
43 33 529 G
64 21 16 G
54 29 759 G
53 28 774 G
30 38 339 G
52 12 975 G
1 59 54 G
12 38 188 G
2 40 75 G
58 55 204 G
3 38 546 G
68 49 534 G
9 52 758 G
13 51 838 G
6 28 28 G
61 55 699 G
42 36 794 G
65 31 171 G
5 74 935 G
11 81 256 G
67 11 733 G
46 59 715 G
8 4 902 G
21 26 1...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
39711
40004

result:

ok 81 numbers

Test #54:

score: 0
Accepted
time: 3ms
memory: 3584kb

input:

84 84
58 17 294 G
67 51 344 G
77 60 997 G
55 5 974 G
12 3 612 G
11 10 967 G
14 29 469 G
42 20 831 G
15 33 430 G
31 39 468 G
76 62 26 G
78 18 854 G
47 41 455 G
53 81 233 G
70 38 238 G
9 30 582 G
36 15 93 G
47 84 776 G
11 27 842 G
60 61 303 G
82 23 182 G
24 64 273 G
66 27 452 G
75 11 833 G
39 71 517 G...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
40976
41681

result:

ok 84 numbers

Test #55:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

83 83
48 71 533 G
33 20 705 G
16 10 409 G
2 39 454 G
26 51 382 G
51 58 467 G
72 42 388 G
43 46 691 G
83 9 735 G
66 77 373 R
41 61 414 G
25 76 128 G
82 83 358 G
75 47 508 G
21 38 850 G
20 25 169 G
11 77 120 G
2 29 266 G
24 11 65 G
52 65 396 G
19 59 133 G
38 22 60 G
26 77 998 G
8 70 49 G
57 55 593 G
4...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
38912
39285

result:

ok 83 numbers

Test #56:

score: 0
Accepted
time: 3ms
memory: 3560kb

input:

90 90
8 41 9 G
56 49 1 G
17 37 30 G
23 48 1 G
85 30 2 G
69 46 146 G
5 49 301 G
78 56 98 G
82 42 106 G
61 60 1 G
61 77 104 G
24 23 144 G
6 4 76 G
52 83 767 G
1 30 1 G
13 72 1 G
63 29 137 G
24 11 9 G
85 28 3 G
87 71 12 G
36 25 1 G
27 71 392 G
49 59 23 G
36 79 216 B
15 44 5 G
42 8 11 G
48 10 59 G
67 66...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13100
13316

result:

ok 90 numbers

Test #57:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

83 83
49 25 851 B
69 54 95 G
4 78 378 G
67 42 46 G
29 60 241 G
21 71 457 G
34 72 53 G
73 50 16 G
57 33 428 G
40 9 256 G
69 77 455 G
82 58 739 G
35 73 407 G
66 32 896 G
33 80 6 G
59 73 273 G
14 17 824 G
41 73 128 G
26 14 972 G
6 63 828 G
71 66 667 G
11 54 948 G
64 63 910 G
13 16 966 G
4 12 73 G
21 81...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
40377
41228

result:

ok 83 numbers

Test #58:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

88 88
13 60 644 G
46 16 612 G
85 67 461 G
73 63 185 G
3 9 303 G
31 1 534 G
55 37 710 G
65 70 32 G
64 27 126 G
68 34 437 G
76 4 14 G
9 23 942 G
45 10 74 G
62 65 141 G
48 33 620 G
52 8 506 G
38 86 837 G
61 11 519 G
36 32 145 G
30 65 388 G
79 50 465 G
2 67 384 G
88 3 344 G
8 35 894 G
28 49 26 G
17 88 3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
40037
40225

result:

ok 88 numbers

Test #59:

score: 0
Accepted
time: 3ms
memory: 3668kb

input:

84 84
58 81 549 G
52 29 58 G
68 37 575 G
70 32 19 G
16 79 110 G
7 59 922 G
51 21 986 G
73 65 289 G
9 57 906 G
83 70 860 G
65 1 922 G
41 3 10 G
52 77 196 G
32 52 649 G
7 8 118 G
76 55 289 G
2 53 731 G
56 5 628 G
61 37 579 G
27 28 46 G
62 64 376 G
40 59 651 G
25 60 14 G
12 67 628 G
14 19 239 G
18 33 6...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
41924
42403

result:

ok 84 numbers

Test #60:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

94 94
33 54 62 G
82 31 499 G
80 45 57 G
44 18 370 G
83 20 501 G
90 10 666 G
44 71 694 G
5 48 22 G
70 84 530 G
67 78 630 G
12 13 554 G
84 61 143 G
74 9 332 G
5 89 865 G
26 56 969 G
43 28 428 G
85 10 748 G
41 12 419 G
68 39 338 G
82 52 166 G
50 15 462 G
75 34 905 G
39 41 261 G
53 29 928 G
42 29 379 G
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
45017
45684

result:

ok 94 numbers

Test #61:

score: 0
Accepted
time: 2ms
memory: 3672kb

input:

93 93
9 58 986 G
90 24 467 G
32 52 353 G
67 45 757 G
70 61 314 G
2 56 767 G
42 92 583 G
63 17 590 G
43 34 140 G
78 21 920 G
12 5 884 G
66 13 173 G
6 27 123 G
81 75 789 G
22 63 472 G
84 14 11 R
75 55 930 G
50 8 840 G
13 48 409 G
70 14 850 G
56 73 302 G
8 13 539 G
74 75 583 G
37 11 334 G
88 49 999 G
3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
48253
48264

result:

ok 93 numbers

Test #62:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

89 89
9 75 137 G
29 28 117 G
53 59 910 G
85 18 691 G
1 47 38 G
23 12 690 G
40 18 359 G
80 62 671 G
74 79 288 G
80 27 561 G
88 73 80 B
13 57 102 G
66 88 947 G
29 68 370 G
66 50 634 G
72 23 899 G
17 32 672 G
24 15 200 G
42 67 3 G
34 59 592 G
8 56 970 G
89 64 929 G
36 7 922 G
32 52 260 G
14 42 215 G
41...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
45739
45819

result:

ok 89 numbers

Test #63:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

84 84
43 60 421 G
25 48 847 G
65 40 477 G
30 7 664 G
11 26 836 G
7 82 465 G
60 77 545 G
64 17 655 G
26 77 498 G
80 39 575 G
78 20 435 G
58 16 280 G
12 52 732 G
50 46 37 G
65 57 611 G
33 44 18 G
81 54 492 G
59 8 890 G
55 34 886 G
33 3 284 G
27 30 741 G
38 74 85 G
81 15 199 G
77 13 539 G
6 46 300 G
2 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
42136
42982

result:

ok 84 numbers

Test #64:

score: 0
Accepted
time: 3ms
memory: 3668kb

input:

94 94
46 40 673 G
79 15 259 G
32 68 709 G
8 43 7 G
6 35 491 G
26 64 262 G
43 56 4 G
75 12 993 G
71 15 283 G
8 53 600 G
16 87 579 G
82 58 402 G
32 59 817 G
29 80 597 G
63 20 203 G
64 39 584 G
81 40 163 G
2 13 197 G
64 88 154 G
79 11 314 G
46 56 888 G
34 38 468 G
32 93 15 G
13 73 520 G
89 14 852 G
86 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
46109
46919

result:

ok 94 numbers

Test #65:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

93 93
21 35 973 G
58 7 707 G
46 51 601 G
91 48 598 G
52 32 856 G
22 76 45 G
93 62 574 G
25 15 296 G
86 25 778 G
13 31 403 G
81 78 769 G
66 69 654 G
26 42 198 G
34 26 670 G
52 46 295 G
11 9 46 G
47 50 679 G
89 37 590 G
81 37 393 G
89 13 357 G
30 69 263 G
74 53 219 G
66 75 97 G
30 44 440 G
45 49 296 G...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
46286
46300

result:

ok 93 numbers

Test #66:

score: 0
Accepted
time: 3ms
memory: 3656kb

input:

90 90
22 71 487 G
15 48 516 G
65 7 766 G
20 70 161 G
30 62 513 G
67 4 290 G
58 4 933 G
57 73 672 G
66 49 925 G
89 54 53 G
31 30 639 G
1 31 651 G
39 37 945 G
46 68 749 G
28 29 695 G
16 28 842 G
65 61 371 G
76 27 666 G
9 5 887 G
22 51 299 G
49 50 899 G
27 10 738 G
85 20 888 G
10 88 879 G
46 18 282 G
3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
46902
47660

result:

ok 90 numbers

Test #67:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

92 92
33 49 403 G
9 35 989 G
32 19 995 G
71 42 2 G
79 43 12 G
11 74 234 G
72 45 516 G
84 39 372 G
39 83 333 G
41 25 822 G
74 4 134 G
75 5 831 G
73 41 848 G
16 4 247 G
10 69 691 G
54 18 928 G
35 1 638 G
10 71 657 G
48 78 700 G
51 73 961 G
16 31 831 G
54 87 543 G
17 37 931 G
75 74 506 G
66 89 431 G
5 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
51367
51602

result:

ok 92 numbers

Test #68:

score: 0
Accepted
time: 3ms
memory: 3528kb

input:

81 81
68 40 754 G
48 57 573 G
34 77 491 G
9 29 149 G
34 10 733 G
63 32 649 G
77 59 326 G
75 26 249 G
1 44 641 G
49 75 62 G
31 17 399 G
75 16 800 G
75 15 265 G
66 24 713 G
45 59 921 G
55 27 81 G
28 30 876 G
38 10 119 G
26 79 499 G
33 34 90 G
74 21 639 G
19 62 823 G
22 8 212 G
62 40 697 G
46 33 716 G
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
41974
42885

result:

ok 81 numbers

Test #69:

score: 0
Accepted
time: 3ms
memory: 3532kb

input:

97 97
64 45 416 G
19 17 450 G
83 49 826 G
85 92 302 G
6 20 514 G
34 58 611 G
95 22 939 G
80 62 872 G
11 35 894 G
71 91 494 G
90 56 775 G
71 8 64 G
59 43 281 B
17 50 589 G
55 29 25 G
86 73 262 G
52 38 218 G
88 42 329 G
87 33 542 G
78 26 592 G
42 79 301 G
81 56 574 G
29 26 429 G
15 75 465 G
92 23 199 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
47835
48116

result:

ok 97 numbers

Test #70:

score: 0
Accepted
time: 3ms
memory: 3588kb

input:

84 84
27 48 196 G
43 78 35 G
28 16 806 G
4 49 10 G
7 64 205 G
60 65 221 G
11 55 112 G
20 53 917 G
35 84 63 G
2 57 215 G
77 62 420 G
77 47 625 G
21 51 176 G
20 69 618 G
38 4 284 G
37 59 307 G
15 65 563 G
56 57 466 G
38 5 815 G
54 29 859 G
39 31 788 G
2 43 169 B
35 56 211 G
70 48 55 G
71 56 397 G
67 6...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
38885
39054

result:

ok 84 numbers

Test #71:

score: 0
Accepted
time: 3ms
memory: 3584kb

input:

85 85
57 85 629 G
30 66 469 G
20 82 814 G
32 48 835 G
67 21 530 G
28 66 533 G
10 70 321 G
9 34 706 G
34 62 504 G
76 83 951 G
38 61 24 G
18 79 196 G
79 46 717 G
29 38 48 G
2 17 621 G
38 17 366 G
2 44 485 G
51 6 742 G
19 54 936 G
13 60 968 G
47 12 849 G
72 51 556 G
37 75 665 G
23 76 844 G
63 52 906 G
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
44154
45149

result:

ok 85 numbers

Test #72:

score: 0
Accepted
time: 27ms
memory: 3800kb

input:

41 98
1 2 70 G
1 41 5 R
2 41 5 B
1 3 50 G
2 4 50 G
3 4 1 G
3 41 5 B
4 41 5 R
3 5 50 G
4 6 50 G
5 6 70 G
5 41 5 R
6 41 5 B
5 7 50 G
6 8 50 G
7 8 1 G
7 41 5 B
8 41 5 R
7 9 50 G
8 10 50 G
9 10 70 G
9 41 5 R
10 41 5 B
9 11 50 G
10 12 50 G
11 12 1 G
11 41 5 B
12 41 5 R
11 13 50 G
12 14 50 G
13 14 70 G
13...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1470
1430
1390
1350
1310
1270
1230
1190
1150
1110
1090
1070
1050
1030
1010
990
970
950
930
910
940
970
1000
1030
1060
1090
1120
1150
1180
1210
1260
1310
1360
1410
1460
1510
1560
16...

result:

ok 98 numbers