import shutil
from pathlib import Path

path = Path('../.legacy')

shutil.rmtree('../tests')
Path('../tests').mkdir()

for file in path.iterdir():
	filename = file.parts[-1]
	if filename.endswith('.out'):
		file.copy(f'../tests/{filename}')		
	
	if filename.endswith('.in'):
		new_file = Path(f'../tests/{filename}')
		with file.open('r') as out:
			with new_file.open('w') as inp:
				# size of the sequence and number of queries
				n, q = map(int, out.readline().split(' '))
				inp.write(f'{n} {q}\n')
				
				# contents of the sequence 
				a_seq = out.readline()
				inp.write(a_seq)
				
				# queries
				for q_idx in range(q):
					t, a, b = out.readline().split(' ')
					
					if t == '2':
						t = '3'
						
					inp.write(f'{t} {a} {b}')
