const
	maxn = 2000;
	maxm = 10000;
var
	n, m, s, pmax, i: longint;
	src, dst, wei: array [1..maxm] of longint;
	who: array [1..maxn] of char;
	str: array [1..maxn] of longint;
	p: array [1..maxn] of longint;
begin
	randseed := 927340274;

	n := 20;
	m := 300;

	s := random(n) + 1;

	pmax := 200;

	for i := 1 to n do begin
		p[i] := random(pmax + 1);
		who[i] := char(ord('A') + random(2));
	end;
    
    for i := 1 to n do begin
    	src[i] := i;
    	dst[i] := random(n) + 1;
    	wei[i] := p[dst[i]] - p[src[i]];
    	str[src[i]] := i;
    end;

    for i := n + 1 to m do begin
    	src[i] := random(n) + 1;
    	dst[i] := random(n) + 1;
    	wei[i] := p[dst[i]] - p[src[i]];
    	if (random(2) = 0) then
    		str[src[i]] := i;
    end;

    writeln(n, ' ', m);
    for i := 1 to n do begin
    	write(who[i]);
    end;             
    writeln;
    writeln(s);
    for i := 1 to m do begin
    	writeln(src[i], ' ', dst[i], ' ', wei[i]);
    end;
    for i := 1 to n do begin
    	if (who[i] = 'A') then
    		write(str[i])
    	else
    		write(0);
    	if (i < n) then
    		write(' ');
    end;
    writeln;
end.