import pathlib,sys
role,root=sys.argv[1:3]
p=pathlib.Path(root)
(p/(role+'.ready')).write_text('ready\n')
print(role.upper()+'_READY',flush=True)
with (p/(role+'.fifo')).open() as gate:
    print(role.upper()+'_RELEASED '+gate.read().strip(),flush=True)
