QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227195#1971. HezardastanrfpermenAC ✓51ms11872kbC++176.4kb2023-10-27 01:22:132023-10-27 01:22:14

Judging History

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

  • [2023-10-27 01:22:14]
  • 评测
  • 测评结果:AC
  • 用时:51ms
  • 内存:11872kb
  • [2023-10-27 01:22:13]
  • 提交

answer

#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;
template<class A, class B>
ostream& operator<<(ostream& os, const pair<A, B> &p) {
  os << '(' << p.first << ',' << p.second << ')';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T> &v) {
  os << '{';
  bool osu = 1;
  for(auto &i : v) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}
template<class T>
ostream& operator<<(ostream& os, const deque<T> &v) {
  os << '{';
  bool osu = 1;
  for(auto &i : v) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}
template<class T,long long unsigned int size>
ostream& operator<<(ostream& os, const array<T,size> &arr) {
  os << '{';
  bool osu = 1;
  for(auto &i : arr) { if(!osu) os << ','; os << i; osu = 0; }
  os << '}';
  return os;
}

#define ll long long
#define ull unsigned long long
#define lll __int128
#define rep(i,n,N) for(int i=(n);i<=(N);++i)
#define For(i,n,N) for(int i=(n);i< (N);++i)
#define rap(i,n,N) for(int i=(n);i>=(N);--i)
#define rip(i,n,N,V) for(int i=(n);i<=(N);i+=V)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
//#define le left
//#define ri right
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define debug(x) cout << #x << " -> " << (x) << endl
#define out(x,y) cout << ">> " << (x) << " " << (y) << endl
#define ou3(x,y,z) cout << ">> " << (x) << " " << (y) << " " << (z) << endl
#define mems(x,y) memset(&x,y,sizeof x)
#define memsv(x,y) memset(&x[0], y, sizeof(x[0]) * x.size())
#define popcount __builtin_popcountll
#define clz(x) (1<<(31-__builtin_clz(x)))
#define clzll(x) (1LL<<(63-__builtin_clzll(x)))
#define all(x) x.begin(),x.end()
#define rsort(x) sort(x), reverse(x)
#define revsort(a,b) sort(a,b), reverse(a,b)
#define PQ(T) priority_queue<T>
#define PQr(T) priority_queue<T, vector<T>, greater<T>>
#define permute(x) while(next_permutation(all(x)))
#define distinct(x) x.erase(unique(all(x)),x.end())
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vll vector<ll>
#define vlll vector<pll>
#define vvll vector<vll>
#define ari(x) array<int,x>
#define arll(x) array<ll,x>
#define ard(x) array<double,x>
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define pllll pair<pll,pll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl '\n'
const int MAX = 1e3+5;
const int MOD = 1000000007;
const ll MOD2 = 2010405347;
const ll INF = 2e18;
const int dr[]={1,-1,0,0,1,1,-1,-1};
const int dc[]={0,0,-1,1,1,-1,1,-1};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 500;
inline ll pw(ll x,ll y,ll md=MOD){ll ret=1;x%=md;while(y){if(y&1)ret=ret*x%md;x=x*x%md,y>>=1;}return ret;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,q,cv[128];
char vc[37];
string s;
bool st[MAX];
vector<string> g[2];
ari(2) x[MAX], id;

struct trie{
	int nx[37],eow=0,sz=0;
}tr[MAX*10][2];

struct triee{
	vector<pair<int,char>> nx;
	int sz,eow,val;
}v[MAX*10][2];

void ins(int z){
	int nw;
	rep(o,0,1){
		nw = 0;
		for(auto i:s){
			if(!tr[nw][o].nx[i])tr[nw][o].nx[i] = ++id[o];
			nw = tr[nw][o].nx[i];
			tr[nw][o].sz++;
		}
		tr[nw][o].eow = z;
		if(!o)reverse(all(s));
	}
	return;
}

void dfs(int nw,int o){
	v[nw][o].val = st[v[nw][o].eow];
	for(auto i:v[nw][o].nx){
		dfs(i.fi, o);
		v[nw][o].val+= v[i.fi][o].val;
	}
	return;
}

string bt;
void dfs2(int nw,int o,int at){
	if(!at && v[nw][o].val==v[nw][o].sz){
		++id[o];
		at = id[o];
		g[o].pb(bt);
	}
	if(st[v[nw][o].eow]){
		if(at){
			x[v[nw][o].eow][o] = at;
		}
		else {
			++id[o];
			bt+= ' ';
			g[o].pb(bt);
			x[v[nw][o].eow][o] = id[o];
			bt.pob();
		}
	}
	for(auto i:v[nw][o].nx){
		bt+= i.se;
		dfs2(i.fi, o, at);
		bt.pob();
	}
	return;
}

namespace MCBM{
	int match[MAX];
	int vis[MAX], cl;
	vi v[MAX];
	int aug(int l) {
		if(vis[l]==cl) return 0;
		vis[l] = cl;
		for(auto r : v[l]) if(match[r] == -1 || aug(match[r])) {
			match[r] = l;
			return 1;
		}
		return 0;
	} // do not forget to reset vis[]
	
	vi cover(int n, int m) { // Backtrack mincover
		mems(match, -1);
		int res = 0;
		rep(i, 1, n)++cl, res += aug(i);
		vector<bool> lfound(n + 1, true), seen(m + 1, false);
		rep(i, 1, m) if(match[i] != -1) lfound[match[i]] = false;
		vi q, cover;
		rep(i, 1, n) if(lfound[i]) q.pb(i);
		while(!q.empty()) {
			int i = q.back();
			q.pop_back();
			lfound[i] = 1;
			for(int e : v[i]) if(!seen[e] && match[e] != -1) {
				seen[e] = true;
				q.pb(match[e]);
			}
		}
		rep(i, 1, n) if(!lfound[i]) cover.pb(i);
		rep(i, 1, m) if(seen[i]) cover.pb(n + i);
		assert(cover.size() == res);
		return cover;
	}
}

int cl,gg[MAX][MAX];

int main(){
//	cout<<fixed<<setprecision(10);
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int ii = 0;
	rep(i,'A','Z')cv[i] = ii, vc[ii] = i, ii++;
	rep(i,'0','9')cv[i] = ii, vc[ii] = i, ii++;
	cv['-'] = ii, vc[ii] = '-';
	cin>>n>>q;
	rep(i,1,n){
		cin>>s;
		for(auto &i:s)i = cv[i];
		ins(i);
	}
	rep(o,0,1){
		rep(i,0,id[o]){
			v[i][o].sz = tr[i][o].sz;
			v[i][o].eow = tr[i][o].eow;
			rep(j,0,36)if(tr[i][o].nx[j]){
				v[i][o].nx.pb({tr[i][o].nx[j], vc[j]});
			}
		}
	}
	int k,a;
	while(q--){
		cin>>k;
		mems(st, 0);
		rep(i,1,k){
			cin>>a;
			st[a] = 1;
		}
		if(k==n){
			cout<<n*1000+1<<" 1 *\n";
			continue;
		}
		else if(k==0){
			cout<<"0 0\n";
			continue;
		}
//		cout<<"---\n";
		rep(o,0,1){
			g[o] = {""};
			id[o] = 0;
			dfs(0, o);
			dfs2(0, o, 0);
			for(auto &i:g[o]){
				if(i.back()!=' ')i = i + "*";
				else i.pob();
				if(o)reverse(all(i));
			}
//			debug(g[o]);
//			debug(id[o]);
		}
		++cl;
		rep(i,1,n)MCBM::v[i].clear();
		rep(i,1,n)if(st[i] && gg[x[i][0]][x[i][1]]!=cl){
			gg[x[i][0]][x[i][1]] = cl;
			MCBM::v[x[i][0]].pb(x[i][1]);
		}
		vi ans = MCBM::cover(id[0], id[1]);
		cout<<k*1000+ans.size()<<" "<<ans.size();
		for(auto i:ans){
			if(i<=id[0])cout<<" "<<g[0][i];
			else {
				i-= id[0];
				cout<<" "<<g[1][i];
			}
		}
		cout<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 7
K-PAX SIRIUS REGULUS ARCTURUS BELLATRIX ANDROMEDA CYGNUS SCORPIUS
8 1 2 3 4 5 6 8 7
6 2 3 4 7 8 6
5 1 2 3 5 8
3 5 6 7
2 2 8
0
1 1

output:

8001 1 *
6002 2 A* *S
5003 3 R* S* *X
3003 3 AN* B* C*
2001 1 S*
0 0
1001 1 K*

result:

ok correct

Test #2:

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

input:

1 2
A
0
1 1

output:

0 0
1001 1 *

result:

ok correct

Test #3:

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

input:

2 4
A B
1 2
0
1 1
2 1 2

output:

1001 1 B*
0 0
1001 1 A*
2001 1 *

result:

ok correct

Test #4:

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

input:

1 2
AB
0
1 1

output:

0 0
1001 1 *

result:

ok correct

Test #5:

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

input:

2 4
A AB
2 1 2
0
1 1
1 2

output:

2001 1 *
0 0
1001 1 A
1001 1 AB*

result:

ok correct

Test #6:

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

input:

2 4
A BA
1 2
2 1 2
0
1 1

output:

1001 1 B*
2001 1 *
0 0
1001 1 A*

result:

ok correct

Test #7:

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

input:

3 8
A B C
2 2 3
2 1 2
1 3
0
1 2
3 3 2 1
2 3 1
1 1

output:

2002 2 B* C*
2002 2 A* B*
1001 1 C*
0 0
1001 1 B*
3001 1 *
2002 2 A* C*
1001 1 A*

result:

ok correct

Test #8:

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

input:

1 2
ABC
1 1
0

output:

1001 1 *
0 0

result:

ok correct

Test #9:

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

input:

2 4
AB ABC
0
2 2 1
1 1
1 2

output:

0 0
2001 1 *
1001 1 AB
1001 1 ABC*

result:

ok correct

Test #10:

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

input:

2 4
A ABC
1 2
0
1 1
2 1 2

output:

1001 1 AB*
0 0
1001 1 A
2001 1 *

result:

ok correct

Test #11:

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

input:

3 8
A AB ABC
2 3 1
0
2 2 1
1 1
3 1 3 2
2 2 3
1 3
1 2

output:

2002 2 A ABC*
0 0
2002 2 A AB
1001 1 A
3001 1 *
2001 1 AB*
1001 1 ABC*
1001 1 AB

result:

ok correct

Test #12:

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

input:

803 100
CQ3WDIY3SD BI5AFJ9MMR B6O7ET7572 CQGMC7R4WD BAHSOB3SR2 WC77BFVCP2 C8W28TZ-TD WAI462U52D CQKN3HAFYD CPXLSU-POR BY5CJJMUH2 B3O1M0QL62 CMDE4OCUM2 B5NHGKPDOR CM1401G-RD WAOI3Z-7XD B4YJB4ID-R CC5POFTRVR B7K5BUCVTD B3BUZ5EAZD CTTY5VAXJ2 BX6YJL2FNR CSH608L01D W2K4RQBSXR B1D8T4AH8D B58M3B-UG2 B28Z04...

output:

130128 128 BA2-* BB5* BCY* BDX* BD0* BEP5* BFH* BFT* BHM* BHW* BJO* BKD* BNB8* BOAQ* BOD* BOJ* BOO* BPH* BPS* BQP* BRU* BSO* BSV* BTO* BVF* BV0* BWU* BX6* BY0* B1O* B1QH* B1T* B1W* B2A* B2Z* B3O* B3RX* B3S* B4Q* B4S* B5Z* B6J* B67* B8U* B91* B9-* B--* CB3* CC-* CDD* CDN* CDW* CD1C* CE-I* CHH* CH9* C...

result:

ok correct

Test #13:

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

input:

206 100
W7NIO4VAN7 3GK-DMGK8U 3KLSUXD4JX WU4CVHWHPX 3OG75G-TRP 3-N7FXW3V7 16B9S6HUT7 TARLAQMG1H TZ3CGBEWQH R9O9SWJ8E7 35RV2QSAR7 RYWFN4WTL0 TD-O-J233U WRHAHADLEU WMSR2GY5S7 WR9HRRXZSP TIRAKFTXPX R753K0P6EP XNLUEDLAEX 188LPIDPKX 37SAM404FU T3ZVREV2WU WN99DYF54P X0KNAKPWOP 35GFCE4IPU WI5W9Z6F3U 16-ADB...

output:

196115 115 RA* RF* RG* RH* RN* RT* RX* RY* RZ* R2* R3* R6* R7* R9* TA* TC* TE* TL* TN* TO* TP* TQ* TV* TW* TX* TY* TZ* T0* T2* T4* T8* WC* WK* WL* WM* WN* WP* WQ* WR* WX* WY* W0* W1* W6* W7* XC* XD* XG* XJ* XL* XS* XV* XW* X0* X2* X3* X4* X5* X7* 1D* 1FC* 1G* 1H* 1I* 1J* 1L* 1R* 1T* 1U* 1X* 1Z* 13* ...

result:

ok correct

Test #14:

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

input:

906 100
AM46Z0MXLJ AZKKLNUMWP T51TW0AZLC ZG9NZVLRSP L-2JMTU-AC FX4DCXQIXJ V2DJKT2GM0 FBYEQNDPSJ F494LP4GS0 V9PFHS3L6J TAUBZFR3BJ TEBM88HU-P T85J5K9EYM AU3G56H2KC ZJN-7TOAPM AP4G4LDHZ0 TDX2Z-UJ20 FE8NYQBYF0 LQKBV2582P FMZRJV54FP ZW9AXZ30OC TK0T82GX6C LVVVD8OIHM ZJTE8YHY1P ZO8-FT36IC ZSLJ1CG6HM TWPWHP...

output:

453389 389 AAD* ABDA* AB0* AB4* AB6* AC0* ADH* ADM* ADY* AED* AEL* AFB* AF1* AF8* AG9* AHF* AHP* AHY* AH4* AH9* AIC* AIJ* AKA* AK2* AMU* AMV* AM4* AN4* AN8* AO* APE* AQ6* ASD* ASG* AU3* AVF* AX* AZA* AZFX* AZK* A0F* A0Q* A0T* A1B* A1L* A2Y* A28* A3E* A3S* A36* A4K* A5RA* A6E* A7E* A7QY* A9B* A9P* A9...

result:

ok correct

Test #15:

score: 0
Accepted
time: 15ms
memory: 10084kb

input:

514 100
HRQQFROGZ6 XKGQ3O3AW6 5CWKWXOKU5 HFJ39F7P0D L3UDP7HL8D K9O976VAHD 0EJ2LC5YL5 UI8JWJS6Z5 LVA-G-ZYR6 USEDOZ12O5 J1DRPLR905 H-JCM3N04D LRFI5-4X5D DQ16KF0PX5 U7GBSAO5L5 0Q78OHWFI5 NETHRINMQ6 JJN1640DA5 4NNXPLA5T5 N85CWUTXK5 K0R7C7LIR6 POLO4L9T7D U8UKB7ZFWD KJ5P0OZEO5 4-23X9ZP55 JC8GJ5JWKD LGZUPC...

output:

354243 243 DBJ* DB-* DHQ* DH5* DL-* DO* DQ1* DT* DW* DZ* D2* D5Q* D8* D-* GA2* GBX* GC* GD* GG* GJ* GKH* GL* GO* GR* GV* GWJ* GY* GZ* G2* G3X* G5* G9U* HB* HEW* HF* HG* HJ* HP* HQ* HRX* HT* HW0* HX6* HZ* H0* H1* H5* H6* H-L* JB* JD* JE* JG5* JH* JJ* JK* JL* JP* JQ* JZQ* JZX* J0* J6* J7* J9* J-* KD* ...

result:

ok correct

Test #16:

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

input:

514 100
L96USRZM0R LZG4B1YBFV LIWW6DYKKJ JKCBL0O-F0 LPSF-KUIFL PZT7W87ODV L3NE13IXZW L-KUJP48RV JVM1BWDL80 JR79AO561V LVPN1QA5XY JVZWNDU8S0 PLMTYPH-W2 J4ZRSDNOEZ LEBE-EEKY2 J9B1G3F2U4 PF1IYLK8TR JE11IW9R2Q J38ZIHGUYZ PJ60-64VLW LNP0RFLERZ L9LHGCCJD0 L-YOS22I-F P3P2LJL2GR LGG4S7E9M2 JFM6IKMRBL JSRAPO...

output:

248215 215 JA3* JBE* JBF* JB0* JC* JDB* JDH* JEJ* JE1* JFW* JF0* JHI* JH2* JIE* JIM* JIV* JJT* JK5* JK9* JL3* JMD* JMM* JMQ* JMY* JNY* JOA* JOT* JPL* JPP* JP1* JQL* JQT* JQ-* JRD* JRQ9* JRR* JR7* JSG* JSO* JSR* JS7* JUA* JVA* JVE* JVK* JVM* JVZ* JXJ* JX2* JYB* JYF* JYY* JZG* J0D* J09* J1F* J10* J12*...

result:

ok correct

Test #17:

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

input:

614 100
WCC4V-YSP5 X-0G-V82N8 KONWGWS5QT OONP33YVOV KOXU-81YIQ URZ9JOEMHY QLJO2235LI -DPZVO00T5 G800H9UIEH -GJPY0XMGT KZVFW4D3OQ 6P3YNNEPLQ 65LAON651X 0H8GORN6-X U5J-YMVT2V XN7CWFHB9T Y5AD68Q4H0 WCIFZRUV-H G4N9HHZ8-5 Y2F-EDA1J1 0MUVY2XLHA 8QW1KN9BL0 -FCCKWVN3T GA548DYM7Y KM72O6FUDG UA0YN1P8PG Q4RBHD...

output:

183159 159 BE* BF* BO* BP* BT* BU* B2I* B4* B63* B8* DD* DF9* DHF* DI* DS* DWO* DYB* DZT* D3* D-J* GA1* GEJ* GE3* GE-* GI* GLD* GNA* GTK* GXH* G1* G3* G6A* KAM* KAY* KB6* KH* KM* KOI* KPD* KPJ* KQ* K0* K4C* K41* K7X* OE* OFG* OTI* OW6* O1T* O4* O5* O7J* O75* O8B* QA7* QC* QD* QN* QV* QWS* QX* Q2* Q8...

result:

ok correct

Test #18:

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

input:

914 100
V5W5MV48VU JVVC804AZ7 YA19I7GKJ4 MFD643KHBF YK3OG4LDZD K2O5DKELDJ RQOI4GLHLF VBFLM3KBOT 7YWHM7AR-8 MRZJY2UGCX 1QJG-FVCKP 74YJ1B58ED CGKOVYQVCP HSIC91T98V JA4ELCIGNU VMYN4KIZ6P K2CQLJJ63C PMY12Y3PC5 PJ5MMWS5OT JGWS986DEP H4WX27KQE7 MAB--0UIM4 RC75BV8PVT UBV6MH5UOC HQAQM9UTRF R6LALTM19D CVLI-Z...

output:

521375 375 CAI* CAR* CB* CD* CE* CIM* CJ* CK6* CO* CPB* CPL* CRV* CV* CZE* CZ9* C0* C1Q* C19* C3* C6* C7T* C8X* HBA* HC1* HD* HER* HF* HGZ* HH* HJ* HK* HM* HP* HWI* HY* H2* H4* H5* H8* JA* JB* JCI* JFD* JFU* JGB* JHB* JI* JJP* JK* JLA* JLS* JL6* JM* JPA* JPD* JPH* JV5* JX* JYY* JZ* J0E* J2* J5Z* J6*...

result:

ok correct

Test #19:

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

input:

923 100
02DU15IS6A U3Z4MW-QQE 82NKKTU-ZS 4SO95XTIC9 OQY-ZQRUGI H3BO76UNN3 857LO29G7J 9CB2LXC-W7 TTVGRPOK87 YMTTM-3RHT H59I7RBBDW 2YUSGOZ5MN 5E43579XBT TRSYI32YQ8 H2X7XL8DLU 25P89DXTNJ DKDOB6UWZ9 D9Y2HW92DO 2J6HDOG8YA ULLOA-QOME WG4OCGW5WO RR2-F6TM73 0QC0XE2IQW 8IAFPQSKNW H61OQEATD9 TQCFQK0WIU D1N0UR...

output:

439343 343 BCE* BE* BG* BHU* BHX* BK* BN* BP* BS* B6* DC* DEK* DEX* DGB* DID* DIK* DM* DO* DS* DWC* D0* D1M* D1T* D3* D8* D9* HCX* HE* HID* HOR* HO4* HP7* HV* HWF* HW0* HX* H3B* H3M* H4* H59* H9* MD* MH* MK0* MLW* MRN* MS* MW* M0* M1-* M2I* M56* M9* OB* OF* OG* OI0* OLG* OM* ON1* OOC* OR* OTP* OY* O...

result:

ok correct

Test #20:

score: 0
Accepted
time: 51ms
memory: 11756kb

input:

990 100
OR4Q33JL64 U93T4VNWIN IMOF-B0WV3 USX1SKBO7Q VIW0ZL0TP9 29GG57V1XU G3I2HH6X7V S4QFQAPINB FGPOZDORVZ 5SBEMSOWJH Y5BRZPO9NU VGTO6I6HRC E8VWBO3HW8 YQUPH-WKB3 BC0QV9QENZ U1L49WWRUI 8JVW5S1XS2 F8355QXKF6 44UJRRIA5B 1RZSC334-H NFH0L3IO8F 5EUS-24K42 UD12L7-T-0 5Y6BEPQBU6 G06SC7KNE3 FXNDDBLBQS 4XMKES...

output:

260232 232 BBQ* BC* BER* BH* BL* BN* B3* B4* B61* B7* EAR* EB* EKJ* ELP* ES-* EWI* EZ* E2* E6K* E6X* E9* E--* FC* FG* FIM* FL* FU* FV-* FW* FY2* F3* F5Y* GE* GO* GP* GQ* GWW* G2* G3X* G5E* IG* IJ* IL9* IPV* IQJ* IV* IYE* IYK* KAO* KD* KG* KK* KN3* KPG* KQ* KX* KZM* KZU* K0* K3A* K5D* K9K* K-I* NCQ* ...

result:

ok correct

Test #21:

score: 0
Accepted
time: 37ms
memory: 10988kb

input:

997 100
3G50RU18DK ZENZYU0RDG P76NNCV6UB JR3PFF3FQU RQN5X4N1KL 8IT3OCB0LI 9MF8L74N5J 9B0672VN1E 4C294ZF3TC J3QD3B5ZBR RO4J6KYPJS UEVEOC0GM3 Z0SVUOMT91 F9V14Q76XY EK4Q04F0PQ 6KFYOYLRSB G2XLU7ZHTA 1W48-OBBHF 20ZF5JERBU 8ZIVSHBH5A QGZRK0TFXJ 3RO-RU5B9N PQB9YMX-1Z YUMGXIGKLS YMMCOGEZF1 BCLZ4M02M3 GHZ60J...

output:

541414 414 AAA* AAS* AB* AF* AL* AM* AQ* ARV* AS* AV* AY* A1* A3* A5* A6* A9* BC* BFTH* BG9* BNY* BQ* BRQ* BR-* BW* BYT* BZO* B1* B2M* B34* B4* B5* B9* DB* DH* DI* DM* DN* DRQ2* DRZ* DUF* DZ* D48* D5* D7* D-* EE* EOD* EP* EQC* E0* E1* E3* E7* FEI* FL* FO* FR* FSF* FW* FYB* F1F* F2* F5V* F6* F9Q* F99...

result:

ok correct

Test #22:

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

input:

2 4
BA CBA
0
1 1
2 1 2
1 2

output:

0 0
1001 1 B*
2001 1 *
1001 1 C*

result:

ok correct

Test #23:

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

input:

998 100
EO0ED0NUTL 1JKH0B5ITH OUJ5KE99ZW 19ZK0WJPO0 H4BFNDS8US 26K4M4MZWP WUV-ZZIEFU WIH2IBRFZL UBA3W8G55S 64-E1A9-JL BTXWZSND80 I-NFNQ4VS6 MG1P3-81S3 MAU4BOHP9H OQ9A8-707P J5Y0R0SEUP -00PJA9ZIL VWLP4WER2H QDXCSZ0T3C 4SOM6N54TN X-EK6X3DW8 05NPZAG0VY JNRF4DPD73 IIRRNXEQBU 2NGLKZ4U33 T63IYYFQ31 FKT6E3...

output:

529413 413 BCA* BFM* BFY* BG* BHL* BHP* BH4* BIU* BL0* BO* BQ0* BQ7* BRQ* BVT* BWL* BX* BZ* B5* B7* B9H* B-* EL* EM* EO2* EO5* ET* E0* E2* E4I* E5* E7* FCY* FF* FH* FJ* FK* FO* FP* FQ1* FU* FW* F1* F2T* F3P* F3R* F45* F-QC* HB6* HF7* HJ* HL* HS* HT* HZ* H01* H4* H6* H8* H-* IB* ID* IE* IF* II* IO* I...

result:

ok correct

Test #24:

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

input:

206 100
3WKWKI20 3WMBMI20 3WO8OI20 3WI6II20 3WK1KI20 3WIHII20 3WKLKI20 3WIKII20 3WK5KI20 3W2F2I20 3WTKTI20 3WK2KI20 3WMNMI20 3WO6OI20 3WKUKI20 3WKXKI20 3WILII20 3WM5MI20 3W2N2I20 3WKPKI20 3WK6KI20 3WO9OI20 3WM0MI20 3WTUTI20 3W282I20 3WKMKI20 3WO3OI20 3WM9MI20 3WTZTI20 3WIDII20 3WKCKI20 3WTGTI20 3WO0...

output:

67067 67 3WIC* 3WII* 3WIK* 3WIO* 3WIS* 3WIT* 3WIW* 3WI0* 3WI2* 3WI6* 3WI9* 3WKH* 3WKJ* 3WKL* 3WKM* 3WKP* 3WKQ* 3WKS* 3WKT* 3WKW* 3WKZ* 3WK2* 3WK4* 3WK8* 3WK-* 3WME* 3WMH* 3WML* 3WMM* 3WMN* 3WMX* 3WM2* 3WM3* 3WM6* 3WM7* 3WOA* 3WOB* 3WOC* 3WOG* 3WOJ* 3WOM* 3WOO* 3WOU* 3WOW* 3WOZ* 3WO0* 3WO3* 3WO4* 3WO...

result:

ok correct

Test #25:

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

input:

999 100
XV0XTXAHJG XV0Z5ZAHJG XV0FIFAHJG XV0XEXAHJG XV0QTQAHJG XV07O7AHJG XV0TATAHJG XV0555AHJG XV0N7NAHJG XV07S7AHJG XV0RTRAHJG XV0TETAHJG XV0OXOAHJG XV0JVJAHJG XV07Q7AHJG XV0BKBAHJG XV0-J-AHJG XV0AOAAHJG XV07Y7AHJG XV0JQJAHJG XV09D9AHJG XV0676AHJG XV0JUJAHJG XV0-4-AHJG XV0T8TAHJG XV0434AHJG XV0RUR...

output:

255255 255 XV0AB* XV0AL* XV0AO* XV0AU* XV0AV* XV0A0* XV0A6* XV0BA* XV0BB* XV0BC* XV0BE* XV0BF* XV0BK* XV0BN* XV0BP* XV0BQ* XV0BU* XV0BV* XV0BY* XV0B8* XV0B9* XV0DB* XV0DC* XV0DN* XV0D5* XV0D7* XV0FF* XV0FM* XV0FR* XV0FS* XV0FT* XV0FY* XV0FZ* XV0F0* XV0F1* XV0F2* XV0F4* XV0F6* XV0F7* XV0F9* XV0HB* XV...

result:

ok correct

Test #26:

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

input:

2 4
A CBA
2 2 1
0
1 1
1 2

output:

2001 1 *
0 0
1001 1 A*
1001 1 C*

result:

ok correct

Test #27:

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

input:

3 8
A BA CBA
1 3
2 3 1
2 2 1
1 1
0
3 2 3 1
1 2
2 3 2

output:

1001 1 C*
2002 2 A* C*
2002 2 A* B*
1001 1 A*
0 0
3001 1 *
1001 1 B*
2001 1 *BA

result:

ok correct

Test #28:

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

input:

2 4
AB AC
1 2
1 1
0
2 1 2

output:

1001 1 AC*
1001 1 AB*
0 0
2001 1 *

result:

ok correct

Test #29:

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

input:

3 8
A AB AC
1 3
2 1 3
3 3 1 2
0
2 3 2
2 2 1
1 1
1 2

output:

1001 1 AC*
2002 2 A AC*
3001 1 *
0 0
2002 2 AB* AC*
2002 2 A AB*
1001 1 A
1001 1 AB*

result:

ok correct

Test #30:

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

input:

2 4
BA CA
1 1
2 1 2
1 2
0

output:

1001 1 B*
2001 1 *
1001 1 C*
0 0

result:

ok correct

Test #31:

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

input:

3 8
A BA CA
2 3 1
0
1 2
1 1
3 3 2 1
2 2 1
2 3 2
1 3

output:

2002 2 A* C*
0 0
1001 1 B*
1001 1 A*
3001 1 *
2002 2 A* B*
2002 2 B* C*
1001 1 C*

result:

ok correct

Test #32:

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

input:

2 4
AB C
1 2
2 2 1
1 1
0

output:

1001 1 C*
2001 1 *
1001 1 A*
0 0

result:

ok correct

Test #33:

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

input:

3 8
A AB C
2 3 2
3 1 2 3
0
1 1
1 2
1 3
2 1 3
2 1 2

output:

2002 2 AB* C*
3001 1 *
0 0
1001 1 A
1001 1 AB*
1001 1 C*
2002 2 A C*
2001 1 A*

result:

ok correct

Test #34:

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

input:

3 8
A BA C
2 3 2
0
3 1 3 2
2 1 2
1 1
1 2
2 1 3
1 3

output:

2002 2 B* C*
0 0
3001 1 *
2001 1 *A
1001 1 A*
1001 1 B*
2002 2 A* C*
1001 1 C*

result:

ok correct

Test #35:

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

input:

4 16
A B C D
2 2 1
1 1
2 3 2
1 2
0
3 3 1 2
2 1 3
4 2 3 1 4
2 4 2
3 1 2 4
3 1 3 4
2 4 1
1 4
2 4 3
1 3
3 2 4 3

output:

2002 2 A* B*
1001 1 A*
2002 2 B* C*
1001 1 B*
0 0
3003 3 A* B* C*
2002 2 A* C*
4001 1 *
2002 2 B* D*
3003 3 A* B* D*
3003 3 A* C* D*
2002 2 A* D*
1001 1 D*
2002 2 C* D*
1001 1 C*
3003 3 B* C* D*

result:

ok correct

Test #36:

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

input:

3 8
AB AC AD
0
2 1 3
1 1
3 2 3 1
1 3
1 2
2 1 2
2 3 2

output:

0 0
2002 2 AB* AD*
1001 1 AB*
3001 1 *
1001 1 AD*
1001 1 AC*
2002 2 AB* AC*
2002 2 AC* AD*

result:

ok correct

Test #37:

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

input:

4 16
A AB AC AD
2 2 4
2 1 3
3 4 2 3
2 2 1
3 1 2 3
2 3 4
4 1 3 4 2
2 4 1
3 1 4 2
1 4
0
1 1
1 3
1 2
3 1 4 3
2 2 3

output:

2002 2 AB* AD*
2002 2 A AC*
3003 3 AB* AC* AD*
2002 2 A AB*
3003 3 A AB* AC*
2002 2 AC* AD*
4001 1 *
2002 2 A AD*
3003 3 A AB* AD*
1001 1 AD*
0 0
1001 1 A
1001 1 AC*
1001 1 AB*
3003 3 A AC* AD*
2002 2 AB* AC*

result:

ok correct

Test #38:

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

input:

3 8
BA CA DA
3 1 3 2
2 2 1
1 1
1 3
2 3 2
2 3 1
0
1 2

output:

3001 1 *
2002 2 B* C*
1001 1 B*
1001 1 D*
2002 2 C* D*
2002 2 B* D*
0 0
1001 1 C*

result:

ok correct

Test #39:

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

input:

4 16
A BA CA DA
1 1
3 4 3 1
1 2
2 1 4
2 1 3
1 3
2 3 4
0
1 4
3 4 2 3
2 2 3
3 1 2 4
2 1 2
4 4 3 2 1
2 4 2
3 1 2 3

output:

1001 1 A*
3003 3 A* C* D*
1001 1 B*
2002 2 A* D*
2002 2 A* C*
1001 1 C*
2002 2 C* D*
0 0
1001 1 D*
3003 3 B* C* D*
2002 2 B* C*
3003 3 A* B* D*
2002 2 A* B*
4001 1 *
2002 2 B* D*
3003 3 A* B* C*

result:

ok correct

Test #40:

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

input:

3 8
AB C D
1 2
2 2 1
1 1
2 3 2
1 3
0
2 3 1
3 2 1 3

output:

1001 1 C*
2002 2 A* C*
1001 1 A*
2002 2 C* D*
1001 1 D*
0 0
2002 2 A* D*
3001 1 *

result:

ok correct

Test #41:

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

input:

4 16
A AB C D
4 3 2 4 1
2 4 2
3 2 3 4
1 1
2 3 4
1 4
1 2
3 3 1 4
3 1 2 4
3 2 1 3
2 1 2
1 3
2 1 3
2 2 3
2 1 4
0

output:

4001 1 *
2002 2 AB* D*
3003 3 AB* C* D*
1001 1 A
2002 2 C* D*
1001 1 D*
1001 1 AB*
3003 3 A C* D*
3002 2 A* D*
3002 2 A* C*
2001 1 A*
1001 1 C*
2002 2 A C*
2002 2 AB* C*
2002 2 A D*
0 0

result:

ok correct

Test #42:

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

input:

4 16
A BA C D
2 4 1
1 1
2 3 4
3 3 1 2
4 4 2 3 1
3 3 1 4
1 4
2 2 1
3 2 1 4
3 4 3 2
2 2 3
2 1 3
0
1 2
1 3
2 2 4

output:

2002 2 A* D*
1001 1 A*
2002 2 C* D*
3002 2 C* *A
4001 1 *
3003 3 A* C* D*
1001 1 D*
2001 1 *A
3002 2 D* *A
3003 3 B* C* D*
2002 2 B* C*
2002 2 A* C*
0 0
1001 1 B*
1001 1 C*
2002 2 B* D*

result:

ok correct

Test #43:

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

input:

3 8
AB AC D
1 3
2 1 3
2 2 3
0
3 3 2 1
1 2
2 1 2
1 1

output:

1001 1 D*
2002 2 AB* D*
2002 2 AC* D*
0 0
3001 1 *
1001 1 AC*
2001 1 A*
1001 1 AB*

result:

ok correct

Test #44:

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

input:

4 16
A AB AC D
3 1 3 2
2 1 4
0
1 3
2 3 4
4 1 2 4 3
3 1 4 2
2 3 1
2 3 2
1 1
2 4 2
1 2
3 4 1 3
1 4
2 2 1
3 3 4 2

output:

3001 1 A*
2002 2 A D*
0 0
1001 1 AC*
2002 2 AC* D*
4001 1 *
3003 3 A AB* D*
2002 2 A AC*
2002 2 AB* AC*
1001 1 A
2002 2 AB* D*
1001 1 AB*
3003 3 A AC* D*
1001 1 D*
2002 2 A AB*
3003 3 AB* AC* D*

result:

ok correct

Test #45:

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

input:

3 8
BA CA D
3 1 3 2
1 3
0
2 3 1
1 2
1 1
2 2 1
2 3 2

output:

3001 1 *
1001 1 D*
0 0
2002 2 B* D*
1001 1 C*
1001 1 B*
2001 1 *A
2002 2 C* D*

result:

ok correct

Test #46:

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

input:

4 16
A BA CA D
2 1 4
2 1 3
3 3 4 1
2 2 3
1 3
2 2 4
1 2
2 2 1
3 4 3 2
1 1
3 2 4 1
3 1 2 3
2 4 3
0
1 4
4 1 2 4 3

output:

2002 2 A* D*
2002 2 A* C*
3003 3 A* C* D*
2002 2 B* C*
1001 1 C*
2002 2 B* D*
1001 1 B*
2002 2 A* B*
3003 3 B* C* D*
1001 1 A*
3003 3 A* B* D*
3001 1 *A
2002 2 C* D*
0 0
1001 1 D*
4001 1 *

result:

ok correct

Test #47:

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

input:

2 4
AB CD
2 2 1
0
1 2
1 1

output:

2001 1 *
0 0
1001 1 C*
1001 1 A*

result:

ok correct

Test #48:

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

input:

3 8
A AB CD
2 2 3
1 1
3 3 1 2
1 2
1 3
0
2 1 2
2 3 1

output:

2002 2 AB* C*
1001 1 A
3001 1 *
1001 1 AB*
1001 1 C*
0 0
2001 1 A*
2002 2 A C*

result:

ok correct

Test #49:

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

input:

3 8
C AB CD
1 1
3 2 1 3
1 3
0
2 1 3
2 3 2
1 2
2 1 2

output:

1001 1 C
3001 1 *
1001 1 CD*
0 0
2001 1 C*
2002 2 A* CD*
1001 1 A*
2002 2 A* C

result:

ok correct

Test #50:

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

input:

4 16
A C AB CD
3 2 1 4
3 2 4 3
2 1 2
0
2 3 2
2 3 1
1 2
1 4
2 4 1
2 4 2
4 1 4 3 2
2 4 3
3 4 3 1
3 1 2 3
1 3
1 1

output:

3002 2 A C*
3002 2 AB* C*
2002 2 A C
0 0
2002 2 AB* C
2001 1 A*
1001 1 C
1001 1 CD*
2002 2 A CD*
2001 1 C*
4001 1 *
2002 2 AB* CD*
3002 2 A* CD*
3002 2 A* C
1001 1 AB*
1001 1 A

result:

ok correct

Test #51:

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

input:

3 8
A BA DC
0
3 1 2 3
2 1 3
1 1
2 2 3
2 1 2
1 2
1 3

output:

0 0
3001 1 *
2002 2 A* D*
1001 1 A*
2002 2 B* D*
2001 1 *A
1001 1 B*
1001 1 D*

result:

ok correct

Test #52:

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

input:

3 8
C BA DC
3 2 3 1
0
1 3
2 3 1
1 2
2 1 2
2 3 2
1 1

output:

3001 1 *
0 0
1001 1 D*
2001 1 *C
1001 1 B*
2002 2 B* C*
2002 2 B* D*
1001 1 C*

result:

ok correct

Test #53:

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

input:

4 16
A C BA DC
2 1 2
3 4 2 1
1 1
1 2
1 3
3 3 4 2
4 2 4 1 3
2 2 3
2 4 1
2 1 3
1 4
2 3 4
3 1 3 4
0
2 4 2
3 3 1 2

output:

2002 2 A* C*
3002 2 A* *C
1001 1 A*
1001 1 C*
1001 1 B*
3002 2 B* *C
4001 1 *
2002 2 B* C*
2002 2 A* D*
2001 1 *A
1001 1 D*
2002 2 B* D*
3002 2 D* *A
0 0
2001 1 *C
3002 2 C* *A

result:

ok correct

Test #54:

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

input:

2 4
ABC D
1 2
0
1 1
2 1 2

output:

1001 1 D*
0 0
1001 1 A*
2001 1 *

result:

ok correct

Test #55:

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

input:

3 8
AB ABC D
1 2
0
3 3 2 1
1 1
2 1 2
2 3 1
2 3 2
1 3

output:

1001 1 ABC*
0 0
3001 1 *
1001 1 AB
2001 1 A*
2002 2 AB D*
2002 2 ABC* D*
1001 1 D*

result:

ok correct

Test #56:

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

input:

3 8
A ABC D
2 2 3
1 1
2 1 3
1 2
0
2 2 1
3 3 1 2
1 3

output:

2002 2 AB* D*
1001 1 A
2002 2 A D*
1001 1 AB*
0 0
2001 1 A*
3001 1 *
1001 1 D*

result:

ok correct

Test #57:

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

input:

4 16
A AB ABC D
1 3
1 2
4 1 3 4 2
2 2 1
2 2 3
1 1
2 1 3
3 2 1 4
3 4 1 3
0
2 2 4
1 4
3 3 1 2
2 4 1
2 4 3
3 4 2 3

output:

1001 1 ABC*
1001 1 AB
4001 1 *
2002 2 A AB
2001 1 AB*
1001 1 A
2002 2 A ABC*
3003 3 A AB D*
3003 3 A ABC* D*
0 0
2002 2 AB D*
1001 1 D*
3001 1 A*
2002 2 A D*
2002 2 ABC* D*
3002 2 AB* D*

result:

ok correct

Test #58:

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

input:

3 8
BA CBA D
3 3 1 2
2 2 3
0
1 3
1 2
2 1 2
2 3 1
1 1

output:

3001 1 *
2002 2 C* D*
0 0
1001 1 D*
1001 1 C*
2001 1 *A
2002 2 B* D*
1001 1 B*

result:

ok correct

Test #59:

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

input:

3 8
A CBA D
3 3 2 1
1 1
0
2 2 1
1 2
2 2 3
1 3
2 1 3

output:

3001 1 *
1001 1 A*
0 0
2001 1 *A
1001 1 C*
2002 2 C* D*
1001 1 D*
2002 2 A* D*

result:

ok correct

Test #60:

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

input:

4 16
A BA CBA D
2 3 2
2 4 1
1 3
1 4
2 2 4
0
3 1 2 4
3 1 2 3
1 1
2 2 1
1 2
4 1 4 2 3
2 1 3
3 3 2 4
3 1 4 3
2 3 4

output:

2001 1 *BA
2002 2 A* D*
1001 1 C*
1001 1 D*
2002 2 B* D*
0 0
3003 3 A* B* D*
3001 1 *A
1001 1 A*
2002 2 A* B*
1001 1 B*
4001 1 *
2002 2 A* C*
3002 2 D* *BA
3003 3 A* C* D*
2002 2 C* D*

result:

ok correct

Test #61:

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

input:

2 4
ABC AD
1 2
0
1 1
2 2 1

output:

1001 1 AD*
0 0
1001 1 AB*
2001 1 *

result:

ok correct

Test #62:

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

input:

3 8
AB ABC AD
1 2
1 1
3 2 3 1
2 2 3
1 3
0
2 3 1
2 2 1

output:

1001 1 ABC*
1001 1 AB
3001 1 *
2002 2 ABC* AD*
1001 1 AD*
0 0
2002 2 AB AD*
2001 1 AB*

result:

ok correct

Test #63:

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

input:

3 8
A ABC AD
1 1
2 1 3
2 3 2
1 2
1 3
2 2 1
0
3 2 3 1

output:

1001 1 A
2002 2 A AD*
2002 2 AB* AD*
1001 1 AB*
1001 1 AD*
2002 2 A AB*
0 0
3001 1 *

result:

ok correct

Test #64:

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

input:

4 16
A AB ABC AD
1 1
3 4 2 3
2 3 2
2 1 3
1 3
3 1 3 2
2 1 2
2 4 3
1 2
3 3 1 4
2 1 4
0
3 2 1 4
2 4 2
1 4
4 1 4 2 3

output:

1001 1 A
3002 2 AB* AD*
2001 1 AB*
2002 2 A ABC*
1001 1 ABC*
3002 2 A AB*
2002 2 A AB
2002 2 ABC* AD*
1001 1 AB
3003 3 A ABC* AD*
2002 2 A AD*
0 0
3003 3 A AB AD*
2002 2 AB AD*
1001 1 AD*
4001 1 *

result:

ok correct

Test #65:

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

input:

2 4
CBA DA
0
1 2
1 1
2 1 2

output:

0 0
1001 1 D*
1001 1 C*
2001 1 *

result:

ok correct

Test #66:

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

input:

3 8
BA CBA DA
1 1
2 3 2
1 3
3 1 3 2
0
1 2
2 1 2
2 1 3

output:

1001 1 B*
2002 2 C* D*
1001 1 D*
3001 1 *
0 0
1001 1 C*
2001 1 *BA
2002 2 B* D*

result:

ok correct

Test #67:

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

input:

3 8
A CBA DA
1 2
1 1
0
2 1 2
2 3 1
2 2 3
3 2 1 3
1 3

output:

1001 1 C*
1001 1 A*
0 0
2002 2 A* C*
2002 2 A* D*
2002 2 C* D*
3001 1 *
1001 1 D*

result:

ok correct

Test #68:

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

input:

4 16
A BA CBA DA
1 3
3 3 1 2
2 2 4
2 3 1
2 4 1
4 4 1 3 2
1 1
2 3 4
3 2 4 3
3 4 1 3
2 3 2
3 4 2 1
1 4
0
2 1 2
1 2

output:

1001 1 C*
3002 2 A* *BA
2002 2 B* D*
2002 2 A* C*
2002 2 A* D*
4001 1 *
1001 1 A*
2002 2 C* D*
3002 2 D* *BA
3003 3 A* C* D*
2001 1 *BA
3003 3 A* B* D*
1001 1 D*
0 0
2002 2 A* B*
1001 1 B*

result:

ok correct

Test #69:

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

input:

2 4
ABC ABD
2 1 2
1 1
1 2
0

output:

2001 1 *
1001 1 ABC*
1001 1 ABD*
0 0

result:

ok correct

Test #70:

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

input:

3 8
AB ABC ABD
2 3 1
0
1 2
2 1 2
2 2 3
1 3
1 1
3 2 3 1

output:

2002 2 AB ABD*
0 0
1001 1 ABC*
2002 2 AB ABC*
2002 2 ABC* ABD*
1001 1 ABD*
1001 1 AB
3001 1 *

result:

ok correct

Test #71:

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

input:

3 8
A ABC ABD
2 2 1
2 2 3
0
1 3
3 3 2 1
2 1 3
1 2
1 1

output:

2002 2 A ABC*
2001 1 AB*
0 0
1001 1 ABD*
3001 1 *
2002 2 A ABD*
1001 1 ABC*
1001 1 A

result:

ok correct

Test #72:

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

input:

4 16
A AB ABC ABD
2 2 1
2 2 4
1 4
3 4 2 3
4 2 4 1 3
1 1
2 1 3
1 2
2 1 4
2 3 4
3 2 3 1
0
3 2 4 1
3 3 4 1
1 3
2 3 2

output:

2002 2 A AB
2002 2 AB ABD*
1001 1 ABD*
3001 1 AB*
4001 1 *
1001 1 A
2002 2 A ABC*
1001 1 AB
2002 2 A ABD*
2002 2 ABC* ABD*
3003 3 A AB ABC*
0 0
3003 3 A AB ABD*
3003 3 A ABC* ABD*
1001 1 ABC*
2002 2 AB ABC*

result:

ok correct

Test #73:

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

input:

2 4
CBA DBA
2 2 1
1 1
1 2
0

output:

2001 1 *
1001 1 C*
1001 1 D*
0 0

result:

ok correct

Test #74:

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

input:

3 8
BA CBA DBA
2 3 2
2 2 1
1 3
2 3 1
1 1
3 1 2 3
1 2
0

output:

2002 2 C* D*
2002 2 B* C*
1001 1 D*
2002 2 B* D*
1001 1 B*
3001 1 *
1001 1 C*
0 0

result:

ok correct

Test #75:

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

input:

3 8
A CBA DBA
2 1 2
0
1 2
3 1 3 2
2 1 3
2 2 3
1 3
1 1

output:

2002 2 A* C*
0 0
1001 1 C*
3001 1 *
2002 2 A* D*
2001 1 *BA
1001 1 D*
1001 1 A*

result:

ok correct

Test #76:

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

input:

4 16
A BA CBA DBA
3 1 4 2
2 1 4
1 3
1 1
2 2 3
4 1 4 2 3
2 2 1
2 3 1
3 4 1 3
3 2 1 3
2 4 2
1 2
3 4 2 3
1 4
2 3 4
0

output:

3003 3 A* B* D*
2002 2 A* D*
1001 1 C*
1001 1 A*
2002 2 B* C*
4001 1 *
2002 2 A* B*
2002 2 A* C*
3003 3 A* C* D*
3003 3 A* B* C*
2002 2 B* D*
1001 1 B*
3001 1 *BA
1001 1 D*
2002 2 C* D*
0 0

result:

ok correct

Test #77:

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

input:

1 2
ABCD
0
1 1

output:

0 0
1001 1 *

result:

ok correct

Test #78:

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

input:

2 4
ABCD ABC
0
2 2 1
1 1
1 2

output:

0 0
2001 1 *
1001 1 ABCD*
1001 1 ABC

result:

ok correct

Test #79:

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

input:

2 4
ABCD AB
2 1 2
1 2
0
1 1

output:

2001 1 *
1001 1 AB
0 0
1001 1 ABC*

result:

ok correct

Test #80:

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

input:

3 8
ABCD AB ABC
1 3
0
2 1 3
1 2
2 2 1
2 3 2
1 1
3 1 2 3

output:

1001 1 ABC
0 0
2001 1 ABC*
1001 1 AB
2002 2 AB ABCD*
2002 2 AB ABC
1001 1 ABCD*
3001 1 *

result:

ok correct

Test #81:

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

input:

2 4
ABCD A
1 2
2 2 1
0
1 1

output:

1001 1 A
2001 1 *
0 0
1001 1 AB*

result:

ok correct

Test #82:

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

input:

3 8
ABCD A ABC
2 1 2
1 2
1 3
2 2 3
3 1 2 3
0
2 1 3
1 1

output:

2002 2 A ABCD*
1001 1 A
1001 1 ABC
2002 2 A ABC
3001 1 *
0 0
2001 1 AB*
1001 1 ABCD*

result:

ok correct

Test #83:

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

input:

3 8
ABCD A AB
2 3 2
1 1
2 1 3
2 1 2
3 2 1 3
0
1 2
1 3

output:

2002 2 A AB
1001 1 ABC*
2001 1 AB*
2002 2 A ABC*
3001 1 *
0 0
1001 1 A
1001 1 AB

result:

ok correct

Test #84:

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

input:

4 16
ABCD A AB ABC
2 1 4
1 4
2 4 3
2 2 4
3 3 2 4
4 3 1 2 4
1 2
0
3 3 2 1
1 3
3 1 2 4
1 1
3 1 4 3
2 2 3
2 3 1
2 2 1

output:

2001 1 ABC*
1001 1 ABC
2002 2 AB ABC
2002 2 A ABC
3003 3 A AB ABC
4001 1 *
1001 1 A
0 0
3003 3 A AB ABCD*
1001 1 AB
3002 2 A ABC*
1001 1 ABCD*
3001 1 AB*
2002 2 A AB
2002 2 AB ABCD*
2002 2 A ABCD*

result:

ok correct

Test #85:

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

input:

2 4
DCBA CBA
1 2
2 1 2
0
1 1

output:

1001 1 C*
2001 1 *
0 0
1001 1 D*

result:

ok correct

Test #86:

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

input:

2 4
DCBA BA
1 2
0
2 2 1
1 1

output:

1001 1 B*
0 0
2001 1 *
1001 1 D*

result:

ok correct

Test #87:

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

input:

3 8
DCBA BA CBA
0
3 2 3 1
2 2 3
1 2
2 3 1
1 3
2 1 2
1 1

output:

0 0
3001 1 *
2002 2 B* C*
1001 1 B*
2001 1 *CBA
1001 1 C*
2002 2 B* D*
1001 1 D*

result:

ok correct

Test #88:

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

input:

2 4
DCBA A
1 1
2 1 2
0
1 2

output:

1001 1 D*
2001 1 *
0 0
1001 1 A*

result:

ok correct

Test #89:

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

input:

3 8
DCBA A CBA
2 2 1
3 2 3 1
1 2
2 1 3
2 2 3
0
1 1
1 3

output:

2002 2 A* D*
3001 1 *
1001 1 A*
2001 1 *BA
2002 2 A* C*
0 0
1001 1 D*
1001 1 C*

result:

ok correct

Test #90:

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

input:

3 8
DCBA A BA
2 2 3
0
1 1
2 2 1
3 1 2 3
1 2
1 3
2 1 3

output:

2002 2 A* B*
0 0
1001 1 D*
2002 2 A* D*
3001 1 *
1001 1 A*
1001 1 B*
2001 1 *BA

result:

ok correct

Test #91:

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

input:

4 16
DCBA A BA CBA
4 3 1 4 2
2 1 3
3 4 3 1
1 4
1 2
2 4 2
3 2 3 1
2 4 1
2 1 2
1 3
0
3 3 4 2
1 1
2 3 2
3 2 4 1
2 4 3

output:

4001 1 *
2002 2 B* D*
3001 1 *BA
1001 1 C*
1001 1 A*
2002 2 A* C*
3003 3 A* B* D*
2001 1 *CBA
2002 2 A* D*
1001 1 B*
0 0
3003 3 A* B* C*
1001 1 D*
2002 2 A* B*
3002 2 A* *CBA
2002 2 B* C*

result:

ok correct

Test #92:

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

input:

3 8
AB B BC
3 1 3 2
1 3
2 3 2
2 3 1
1 2
1 1
0
2 2 1

output:

3001 1 *
1001 1 BC*
2001 1 B*
2002 2 A* BC*
1001 1 B
1001 1 A*
0 0
2001 1 *B

result:

ok correct

Test #93:

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

input:

6 64
A AA AAA AAAA AAAAA AAAAAA
2 2 6
3 3 4 6
1 4
4 2 5 6 4
4 1 3 2 5
2 1 4
3 2 4 5
2 6 1
3 5 2 3
3 3 4 2
5 2 5 3 1 6
3 6 5 1
3 2 1 4
4 6 1 4 5
3 1 3 6
4 1 4 3 5
1 3
1 5
4 3 6 1 4
4 4 3 6 5
3 6 4 2
2 2 1
1 1
4 2 4 6 1
2 2 4
0
3 4 3 1
4 2 4 3 6
2 3 5
3 1 5 4
3 6 4 1
5 1 5 4 2 6
6 1 2 5 3 4 6
4 2 5 4 ...

output:

2002 2 AA AAAAAA*
3003 3 AAA AAAA AAAAAA*
1001 1 AAAA
4002 2 AA AAAA*
4004 4 A AA AAA AAAAA
2002 2 A AAAA
3003 3 AA AAAA AAAAA
2002 2 A AAAAAA*
3003 3 AA AAA AAAAA
3003 3 AA AAA AAAA
5004 4 A AA AAA AAAAA*
3002 2 A AAAAA*
3003 3 A AA AAAA
4002 2 A AAAA*
3003 3 A AAA AAAAAA*
4004 4 A AAA AAAA AAAAA
1...

result:

ok correct

Test #94:

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

input:

6 64
A AA AAB ABB BB B
3 1 6 2
3 5 3 1
3 5 6 3
3 2 3 1
2 3 1
6 3 6 5 1 4 2
2 4 3
2 6 3
4 6 5 3 2
3 4 1 5
3 2 5 4
4 4 1 5 6
5 4 1 6 5 2
2 2 1
4 1 3 6 5
3 6 1 5
5 6 5 4 3 1
4 3 2 1 4
1 2
4 4 3 6 1
3 3 6 4
4 3 6 1 2
5 3 6 2 4 5
3 4 3 5
2 1 5
2 2 6
3 4 1 6
3 5 6 2
5 3 2 4 1 5
3 5 6 4
2 4 6
4 1 2 4 6
4 5...

output:

3002 2 B *A
3003 3 A AAB* BB*
3002 2 AAB* B*
3002 2 A AA*
2002 2 A AAB*
6001 1 *
2002 2 AAB* AB*
2002 2 AAB* B
4002 2 AA* B*
3002 2 A *BB
3002 2 AA *BB
4003 3 A AB* B*
5003 3 AB* B* *A
2001 1 *A
4003 3 A AAB* B*
3002 2 A B*
5002 2 A *B
4001 1 A*
1001 1 AA
4004 4 A AAB* AB* B
3003 3 AAB* AB* B
4003 3...

result:

ok correct

Test #95:

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

input:

5 32
ABC BC C CB CBA
2 4 1
3 5 2 1
1 5
3 3 4 5
1 1
2 3 2
2 2 5
1 3
3 3 1 2
2 1 2
1 4
4 4 2 1 5
3 3 2 5
1 2
2 4 2
3 5 4 2
2 1 5
4 1 5 3 2
2 5 4
3 5 3 1
4 1 5 4 3
3 1 2 4
0
3 1 5 4
2 3 1
2 5 3
2 4 3
4 4 1 3 2
3 4 3 2
5 3 1 2 4 5
3 1 3 4
4 4 2 3 5

output:

2002 2 A* CB
3002 2 CBA* *BC
1001 1 CBA*
3001 1 C*
1001 1 A*
2002 2 B* C
2002 2 B* CBA*
1001 1 C
3001 1 *C
2001 1 *BC
1001 1 CB
4002 2 CB* *BC
3003 3 B* C CBA*
1001 1 B*
2002 2 B* CB
3002 2 B* CB*
2002 2 A* CBA*
4002 2 CBA* *C
2001 1 CB*
3003 3 A* C CBA*
4002 2 A* C*
3002 2 CB *BC
0 0
3002 2 A* CB*
...

result:

ok correct

Test #96:

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

input:

6 64
ABCD BCD CD D DC DCB
4 2 6 5 4
3 5 2 6
6 5 3 2 6 1 4
2 1 5
3 6 2 4
2 6 4
4 5 4 3 1
3 6 1 2
0
3 3 2 4
3 1 2 4
5 2 5 1 4 6
2 5 4
4 4 2 6 1
2 1 4
4 1 6 2 3
3 5 6 1
3 1 2 5
2 6 2
3 3 5 6
1 4
1 6
3 4 5 2
3 2 6 3
2 3 6
5 1 4 3 5 2
4 1 5 4 6
3 5 1 4
2 6 5
2 4 2
2 3 5
5 3 6 5 4 1
1 2
3 1 4 6
4 2 6 3 5
...

output:

4002 2 B* D*
3002 2 B* DC*
6001 1 *
2002 2 A* DC
3003 3 B* D DCB*
2002 2 D DCB*
4004 4 A* C* D DC
3002 2 DCB* *BCD
0 0
3003 3 B* C* D
3002 2 D *BCD
5002 2 D* *BCD
2002 2 D DC
4003 3 D DCB* *BCD
2002 2 A* D
4002 2 DCB* *CD
3002 2 A* DC*
3002 2 DC *BCD
2002 2 B* DCB*
3002 2 C* DC*
1001 1 D
1001 1 DCB*...

result:

ok correct

Test #97:

score: 0
Accepted
time: 34ms
memory: 10292kb

input:

1000 100
OAA9YQ5VOZ H4G8T8-AWG 2V8J2DY88H VOTJRYQHSC JIV57RYB4I CKDA7GCT-F 59OT9PN7MV E55SCNCHOI 3QRSJ1Z165 D2LZJ6KCM1 1AZ8X8XYNA UN1EIVMEU6 -6GLAQ459B 4U39QLQWYM 4376K3Z-G6 GO8CUD2615 VDQMQBZD56 PYD65T3YN0 F0HP5LJKAF S8TW3-7HKX 6BLTEOO1VL UZOMT710K1 URAD3ML3W4 S9D6J09WJS M9X7FHI-CT YLWMGUUBBA -MEF0...

output:

506414 414 AN* AO* AQH* AS* A0* A4* BE* BGX* BI* BS* BT* BV* BW* B0* B65* CH* CT8* CX* C0* C2* C6* DH* DL* DM* DO* DP* DQ* DR* DS* DV1* D0* D1X* D5* D9* EB* EDW* EF1* EF-* EI* EN* EO* EQ9* EU* EY* E2* E5H* E6* FB* FH* FM* FNM* FUA* FX* FYJ* FZ* F2TL* F4* GC* GD* GKQ* GO8* GP* GR* G1* G2* G7R* G9* HA...

result:

ok correct

Test #98:

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

input:

629 100
AABAAABABB BABABABAAA BBBBAABAAB AABBBBBAAB BAABBAABAA BABBBBBABA ABAAAABABB AABAAAAABB BABABBBBAB BBABBBABAA BAABBBABAA ABBBBABBAA BBBABBAAAB BBBBAABAAA ABABAABABA AAABAAAAAB ABAABBABBA ABBABBBBAB BBBAAAABBB BBBAABABBA BABBBABBAA AAABAABBBA BBBABBBABB BABBBBBAAB AAABBABBAB AAAABAABBB ABABBB...

output:

316209 209 AAAAAAABAB* AAAAAAABB* AAAAABAAB* AAAAABABBA* AAAABABAAB* AAAABBAABB* AAAABBABA* AAAABBBAA* AAAABBBBA* AAAABBBBBA* AAABAAAAA* AAABAABB* AAABABAAAB* AAABABABBB* AAABBAAAA* AAABBAAABA* AAABBABBAB* AAABBBAAA* AAABBBBA* AABAAAAAB* AABAAABB* AABAABAAB* AABAABBBBA* AABABAAABB* AABABAAB* AABABBA...

result:

ok correct

Test #99:

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

input:

997 100
BABBAABBCB CBCCBACCCA CABACCCBBB BBACABACAA CCCBBCBABC ACCAAACBCC CCCABBBABC CCBABCABBB ABABAABCBB ABACAAABAB ACABCCBBAB BABCABCAAC CCCBABBAAB ABCBCCBABC BBACCCCBBB CAAABBACCC CACAACCAAA BCCCBAABAB CAACCCBCCA CBABBBCCCB CBCACBCBAB ABACCBCBCB ABBCCCCCAA CBCCBABBCA BCABCBBCCB CBAACCBCBC BCBABA...

output:

482337 337 AAAACBCB* AAABAAC* AAABABA* AAABBB* AAACAB* AAACACAC* AAACBBA* AAACCC* AABAABC* AABABAA* AABBBCA* AABBC* AABCA* AABCC* AACACA* AACACC* AACBAC* AACBBA* AACBCBB* AACBCC* AACCAAA* AACCBC* AACCC* ABAAB* ABAACABC* ABABAABC* ABABABA* ABABABCC* ABABBBAABA* ABABBC* ABABCC* ABACAAA* ABACAAC* ABACA...

result:

ok correct

Test #100:

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

input:

1000 100
ADACDEFBF DGGCFBCGF DCGEBCGFC EBDFDCFDD FEDGCAFAG AEBBBFDDB AGGEAEGDF BBACFECCD CDFBBEDCA AGBBAEDBC BCDDGECGE CDGEFEBGA DBGBFGCBA DEABECGDD GDCGBDEEE FEAGEDCAE AGBFABAED FFBBEFEDF DFGBEGEGE CBGBGECAD BADGECBGE DCGBCBEEE ADGAABFFA EEECABDFD FAEEAABBE FEDEDEFFG DFFBGEDEE AACACFAFG BGGFBCBEG D...

output:

501356 356 AAAB* AAAF* AABFBB* AACDF* AACG* AADB* AAE* AAF* AAGF* ABAA* ABBA* ACA* ACBFE* ACCD* ACDA* ACDD* ACFCG* ACG* ADAB* ADAF* ADBDG* ADBG* ADCB* ADCD* ADCEB* ADDAB* ADEB* ADEF* ADF* AEBB* AEBF* AFBD* AFDB* AFDC* AFDG* AFE* AFFE* AFGA* AGBB* AGBD* AGC* AGD* AGEA* AGEB* AGEC* AGEF* AGEG* AGF* AG...

result:

ok correct

Test #101:

score: 0
Accepted
time: 37ms
memory: 11348kb

input:

1000 100
JEEFFJADAF JHCCFJBGFE EAHJCDDBBE GJBHAHJAFF HJCHDIFBEI CICBGFDDHC GHJFGBFAAC DGBFFDFGEE BJHBAGBJAA FAFJCBAJEC JCJJHGIBGI IIIEGDCCBB GEJCHAADDG FFFECHBFHJ IHCEIJEGEI GBEHDBADDA FHJFIDJAJA GCDHDCIABJ CDEFJBCFFB DJFCGCJGGB JJBFEECBAG DJCABDHCJB DEGGHHBCID AGJEGIEDFI CHIJCAJDBG EDIDHCDGGF EFGEE...

output:

487381 381 AAA* AAFA* AAJD* ABA* ABF* ACA* ACEH* ACG* ACH* ACIC* ACJ* ADBF* ADBI* ADBJ* ADDI* ADFF* ADJC* ADJF* AEAE* AEDD* AEE* AEFAD* AEJ* AFE* AFGB* AFH* AFID* AGA* AGC* AGF* AGJD* AHAB* AHAJ* AHBG* AHF* AHHF* AIA* AIJ* AJAH* AJCJ* AJF* AJG* AJJ* BAI* BBA* BBDE* BBG* BBI* BCC* BCD* BCFD* BDCE* BD...

result:

ok correct

Test #102:

score: 0
Accepted
time: 39ms
memory: 10860kb

input:

1000 100
ECNSLCKQCM JEHFECCSEC RIFNTEKGIA SLCKLSFJAC CHGCGBFIOK ISFGQDENGQ NHIALQNSDN MAAGNPMNKO SIPEDOGIGD TDITCLNJGR RMIMIRLBCA MIOHFDOEGQ LLLACCGDRK BSJAMFDETE STHBBGKDEF QHMGOERAPR RAKQHLCDMA PIEDTGLMIO TCNOHCARDD JSMRJMOHOP PCQGKELEOC IHAIFIFDCJ ENLEPKCBJR RITFQMTKJE KFBJOJAASS HIPQRRIFFQ FENNN...

output:

489376 376 AAA* ABA* ABM* ACT* AF* AGL* AHB* AHC* AIG* AIJT* AJC* AL* ANA* ANG* AP* AQL* AQN* ARG* ARJ* AT* BB* BEB* BF* BGD* BGL* BICA* BJL* BLF* BLO* BM* BQ* BRHF* BSP* CB* CCL* CCP* CE* CFI* CFM* CGK* CGQ* CHC* CHG* CIA* CIS* CKK* CQR* CSE* CSR* CT* DC* DD* DEN* DGB* DH* DIB* DMC* DMD* DMF* DNK* ...

result:

ok correct

Test #103:

score: 0
Accepted
time: 8ms
memory: 10240kb

input:

988 100
2Z- B9Y NKK K3G K5Z VF0 TQW UL5 5TI LFI LB3 Y3K T7R GGK S55 YTS 0OF U12 B2C 7T3 M0M 413 B9U YRM KWW FAU SGU 55X 7QZ DCV JJN UE1 H3L O4F 4S8 DMM SA9 1E8 H31 1V3 C7R C9U E31 NL5 23H 6IG 1QI YUZ GF3 LIB 734 FHD B23 M5K 6S5 G4E AUS HET 8R4 F4B 5DH WR2 ER7 56X AOT 8XT WVP SGT V7V TC- RD8 3DW ZOP ...

output:

511411 411 AC* AF* AK* AN* AP* AR* AT* AUW* AY* A3W* A30* A4* A5* BAO* BBX* BD* BH* BMG* BNW* BOG* BO2* BRL* BWZ* B1* B4* B9U* CC* CH* CJ* CQN* CU* C4* C7* C-* DA* DB* DE* DFV* DG* DI* DL* DM* DNB* DNY* DR* D1* D2* D4* D7* D9* EBF* EF* EJT* EK* EL* ER7* ES* EWO* EXL* EZ* E2* E3* E5* E7* FF* FG* FH* ...

result:

ok correct

Test #104:

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

input:

8 100
B5GHG VMYSO W5GHG R5GH1 R5GHJ XMYSD -MYSD VMYSA
8 1 7 2 3 6 8 5 4
2 1 6
8 7 8 5 6 2 4 1 3
2 8 5
7 7 1 6 4 5 8 3
7 8 5 6 2 3 7 4
2 5 4
6 4 8 6 7 1 5
6 3 5 6 4 7 1
8 4 5 2 3 7 8 6 1
0
0
6 3 7 6 5 4 8
0
3 1 6 5
2 6 3
7 1 3 4 6 5 8 2
0
1 6
5 5 1 3 2 7
8 4 5 2 6 8 3 7 1
8 8 7 4 6 2 5 3 1
4 1 8 4 2
...

output:

8001 1 *
2002 2 B* X*
8001 1 *
2002 2 R5GHJ* VMYSA*
7004 4 R* VMYSA* *D *G
7004 4 R* V* W* *D
2001 1 R*
6004 4 B* R* VMYSA* *D
6003 3 R* *D *G
8001 1 *
0 0
0 0
6004 4 R* VMYSA* W* *D
0 0
3003 3 B* R5GHJ* X*
2002 2 W* X*
7004 4 R* V* X* *G
0 0
1001 1 X*
5004 4 R5GHJ* VMYSO* -* *G
8001 1 *
8001 1 *
40...

result:

ok correct

Test #105:

score: 0
Accepted
time: 4ms
memory: 7756kb

input:

100 100
7YP5GHA 38ZITV9 0IT14GW R0HQ62W 7YP5GU9 CEZVHUX 39ZITP- NW8OQ1N Y-ZITV9 8C29D04 7YJ0TF3 0ONZMGV GA4KAY- ANV0JTJ 7F8OQ1M 3TTDDVU EHITSL8 1UOMHCX AG29DYG R0HQ6Q3 ZZHQ60X MX9J0VE M2AZQPZ ESWMLRD E6SP6SC ZJV0JE7 TEKG3IR ESWMLT9 J43DS2B NTITSL8 W2TDD2I ZJV0JG2 AK3PRU3 XMHPRVI JE2-BR2 -SHPRVI 314K...

output:

97033 33 A* CE* C4OMH6* D* E* F* J* L* M* N* O* P* Q* R* T* W* X* Y* ZJ* Z4* 0* 1* 2* 3* 5* 7F* 9* *A *I *M *3 *4 *-
73036 36 AG29DY* AM* C* DE* EA* F* I* L* MX* M2* NW* O6* P9* Q* R* S* T* W* XZHPR7* Y* ZF* ZJ* 0* 1U* 3T* 31* 39* 6* 7Y* 9* *SC *VI *0X *0 *8 *9
43033 33 AG29DY* AK* AN* CE* C4OMH6* D...

result:

ok correct

Test #106:

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

input:

966 100
D-J ULU LRS QTP 1J8 32G -P0 HGI 0BQ 2MG CVH -34 R1G M-N U64 MEN L4Z 0E1 -WC BTJ Y0F KE1 NMA 9L- NX7 UNC 1SL KJS 9VW TXM SB0 4YJ MGW 4TA RMI DKT XX0 12N G6E GNY IL- 8PT LWS ZTC ETQ WGW ZJ9 KP4 MJK ILN HGW 7NE N0S 4N6 T5D Z4Z 0FW WPT VXQ BMW E36 O2M 5B4 342 LUF OTC H2D OFD WLC QB0 LQ6 PGN JT2 ...

output:

589413 413 AGL* AGS* AGZ* AK* AV* AX* AY* A1* BF* BI* BK* BQ* BTP* BU* BV* BZ* B2Q* B9* CI* CL* CMY* CP* CRV* C2L* C6* DEU* DG-* DKP* DR* DT* DU* DX* D0* D4* D72* D-* EFS* EJ* EM* EO* EP* ET* EX* E3* FA7* FG* FP* FU* FV* FX* F0* F-* GD* GG* GIQ* GIR* GJE* GM* GNY* GO* GX* G6* G7L* G8* G-* HC3* HG* H...

result:

ok correct

Test #107:

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

input:

1000 100
FZ0SPZ9 G3MHZIL 238D3G0 QYP4LBI LF9CC0A 9KK8BWH VO3KA2T 0272EZ8 8DU2LLB AAQGQIR -BMTS2U 5JA10-N 05KMNAR BSULLS5 ANTGWW5 QIP5XTC 2FGP-O1 3CFXLED 3-4REN9 ENDT914 5YJ9VOG 1CT-MW8 WXAPKFY 42E3DBO 2RWIVQY QL7IVG4 -S-5LE1 Z1EZL0F Q-R0TCQ 72LM5MG WMT-M8R 1P9J2RH R2VIMQI 9HUEX1Y 5GQ40L1 LV8F-UZ R2Z...

output:

66062 62 AC5XTA* AIRE6H* AQ6U2-* AZ07GS* A8* BYA* DRL93K* GGE220* HB5M2F* IOS2T8* JV5* LC* LG8VPQ* MD0CNB* OR72EX* PHSME2* PTR0T0* P5* QAZ9UU* QBEK* QR* RC* RH* RV0B9C* SI* SMPUA6* SXMS-G* TUKDQN* UBX* UB0* UEZYOD* UKG9ZR* UTQG2W* VJ836I* VQH* WKB* X0S* YL-* YP* 02VQ8T* 1D* 1HJ* 1QGHK0* 10* 2JTPFB* ...

result:

ok correct

Test #108:

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

input:

1000 100
XW42DVU4F SB5J4T44L ZRTETRUAY 1WV5YNL5W -KUVGVDTH 8-HHQABYU IICJUHWF- 2T4OIMA2P 3NWX1CC-0 SVA52M7VW GZ45ZQ7E9 WN1KD91TI Z1OSKWFNB D7T5BS2HM 4DLB87XBH UR0I2UM7H G3UHUA-PP PNS2HPW8O LU5GHYF8E J5KB7U71P D6JC2SE0L QK41JIW00 L43LU9AAP ORZ-Z4-3A 3DPM2LZB2 V5WC2SVZI UY18ISCMR 28EP3OX9T QJZZOWW4L Y...

output:

74072 72 AEF* AN* CVNI6PX* DAW* DH* D0FM2L2* D2PNRFJ* EEB* E3QNJDL* FFJ* FTCCUR6* GXR* G8BGB3Q* HDY* IE* IGJTHXD* IUYETR9* I-E57N2* JN* KD6U192* KQ9R2G3* KTOU3EZ* LG7* LN* LP9DL-9* LU5GHYO* LXAT61P* L43LU9A* NMHG9DL* NNG* P2* QF0E80Z* QK4* RK4DU4G* SLPO9E0* SQPS8LWZ* SZKR-PV* TE* T0YOE4E* UJ* VR1* V...

result:

ok correct

Test #109:

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

input:

1000 100
712P8A2FAM 09H9-JYTOM B64-WIOPAP RSWNYLZZ6K KIG1X2R5D6 AT-FY48HMX K6ZP0YUOR2 AAZEOD8CMZ AEFJY2OJGF PUQ4PX2YG6 13JJMPGBBN E5A9EKZNEE LJOJOVSS7P 46T06QZ49T 2331TV7FCO 39OL9-ILP5 UZF7BVAY2H 2QHPVSYGLF 6SN2FG2OME IU7YWZ9GC3 9ETXQ4QB0I 88X1VKR9T3 L0QZOLR4EZ 7YZWR424MV AHXGIXM5OU TZR-KCO7AI KNGCS...

output:

649411 411 AA* AC* AD* AE* AH* ALVBVEKB* AP* AT* AVM* A0XLGNPI* A3* A5IP8A2Y* A8* BB* BEJ* BL* BN7* BO* BP5XOTR3* BR* BVMBX9N1* BVR* B0* B3* CC* CD* CE* CG5XO6D2* CP* CQ* CV* CW* C42FOJ12* C46* C5* DCK* DC26O5VS* DDI-2NTO* DK* DS* DU* DW* D0* D1* D2M3MOSU* D2V* D5VAK22V* EC* EE* EH* EO* EP* EQ2* EQ6...

result:

ok correct

Test #110:

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

input:

7 100
YDIUW0CI0C YKRVY9W9UY CXWNQYCTNY Y5H9AMVTQY 6GY0UTDYDK 4E-AOS3BQY YGMIQP9RJG
4 6 7 5 2
2 7 3
5 2 1 4 6 7
6 1 7 6 3 5 4
3 4 5 2
6 2 5 6 7 3 1
1 7
2 5 4
2 6 1
0
5 7 5 2 1 4
1 2
1 3
3 4 7 5
0
0
6 7 5 1 6 4 3
3 2 5 4
1 1
2 5 3
4 7 4 3 6
3 7 3 2
6 2 3 4 7 1 6
7 1 7 4 6 3 5 2
2 1 3
5 4 6 1 5 2
4 3 1...

output:

4004 4 YG* YK* 4* 6*
2002 2 C* YG*
5002 2 Y* 4*
6005 5 C* YD* YG* 6* *QY
3003 3 YK* Y5* 6*
6006 6 C* YD* YG* YK* 4* 6*
1001 1 YG*
2002 2 Y5* 6*
2002 2 YD* 4*
0 0
5002 2 Y* 6*
1001 1 YK*
1001 1 C*
3003 3 YG* Y5* 6*
0 0
0 0
6005 5 C* YD* YG* 6* *QY
3003 3 YK* Y5* 6*
1001 1 YD*
2002 2 C* 6*
4003 3 C* Y...

result:

ok correct

Test #111:

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

input:

41 100
V457JG9HW2 G47YX6MZM9 -Y9B0RBO-R 9IXFEC9OPZ FY8NMG70RI WFV1PZQJZK 95QL0GGXHH 7E6W550I27 OVOP4FRQGI K3EHYQSX44 GUT6VPQ0U6 0ZW1DOTBB3 8H-O0XN25K 94T6OMB5D9 JJ3DRJULO- 7TBEPXLFX9 -5EJE1OOIS 75NV774CV4 JNWE-LHDCV YPEU3O9NSF UDJ9JHW1CK ANLA3AA5SZ R49WPX9BNV VOXEXGTN1- KBF96IZBUR JCYUZEUCV4 DGSH3UY...

output:

16016 16 A* GU* GV* I* KQR* K3* T* U* W* Y* 08* 75* 94* -P* -Y* -7*
37018 18 A* D* G* JC* K* T* V* Y* 0* 7* 9* -M* -P* -5* -7* *I *K *V
22016 16 GL* GU* GV* JJ* KQ* T* VO* W* Y* 0E* 9* -M* -7* *I *R *7
23021 21 D* GU* G4* JJ* JN* KB* K3* O* R* U* V4* W* Y* 0Z* 75* 8H* -M* -P* -7* *S *7
6005 5 T* 0Z*...

result:

ok correct

Test #112:

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

input:

802 100
66NUVUSI3X UXJ2YC8BUX -1P28XWYOX 8E7SC98B6X -IUN4JWIFX AS6B37EV-X RX48RJ8754 83CZAB5PUX IVFYVKY7XX AFQXK1UBWX LB2PMW-IYX MFLPGASYOX N3CKSBCEAX DTCQMEKD8X Q3HN1S453X 4IO46G4TGX K22YHJUMF4 GK3FKYJJ1X 5495G5ORGX GDZFX3FQXX TR8-UYG52X 0C1DNGA1DX 2CLMQI73FX GKM-I2MMVX D46EV-41PX 5UCH6UQ5-X 0HYFCA...

output:

460366 366 ACU* AD* AJ* AU* AV* AZX* AZ9* A0* BA* BB* BC* BDQ* BI* BMK* BN* BQI* BQM* BQ9* BQ-* BR* BS* BT* BW* BX* B0E* B0N* B03* B1* B4* CV* CY* C00* C29* C-* DC* DK* DO* DS* DT4* DU* DX* DY* D46* D5* D-* GA* GB* GDY* GK* GQV* GR-* GV* G6* G8* HC* HEE* HE1* HE-* HF* HH* HI* HKX* HP* HR* HVH* HYI* ...

result:

ok correct

Test #113:

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

input:

103 100
95XDA92N7U FOAVHUFZHU 04LTPWAYJL 9KWSIR0GY7 FVLK9X-4L7 087QW2O-DL F54H2VQYRL F4VY6CVW6L 0EV7UJ-PIU 9AEY353TIL FZX8O3YK97 9EQRL2PVWL FQLRGD58ML F-J6L2CMWU 0CE9TP4TEU 90HFRCV227 9RRP5X0QFU 0H1L9HYG8U 0R1S47HXR7 0IQBBGFF0U 0BQ-WQ3LS7 96W0XLKHB7 98WO2SS5YL 04BD1T8QF7 91HPAQI-HU FNOL8M9AMU FCZJHC...

output:

90060 60 FC* FD* FGP* FJ* FL* FN* FOB* FOM* FP* FQ* FU* FVK* FY* F2* F4* F5* F6* F-* 0AN* 0AS* 0B* 0C* 0E* 0G* 0H* 0I* 0J* 0K* 0Q* 0R* 0W* 0Y* 00* 01* 02* 03* 04* 05* 06* 9AE* 9B* 9E* 9G* 9K* 9O* 9Y* 90* 91* 95* 98C* 98Y* *DL *5U *6U *A7 *B7 *S7 *17 *57 *97
8008 8 FJ5* F7* 0GW* 0Y* 05* 0-* 9AE* 91*
...

result:

ok correct