import sys
import os
li = sys.argv
S = li[1]
L = li[2] 
wo = S.split(" ")
com ="""echo " """+S+"""" | apertium """+L
trans = os.popen(com).read();
words = [];
for i in range(len(wo)):
    if len(wo[i])>0:
        words.append(wo[i]);
subseg = [];
for i in range(len(words)):
    temp = words[i];
    subseg.append(words[i])
    j = 1;
    while (i+j)<len((words)):
        temp = temp+" "+words[i+j];
        j = j+1
        subseg.append(temp)
for k in subseg:
	temp ="""echo " """+k+"""" | apertium """+L
	tempTrans = os.popen(temp).read();
	if trans.find(tempTrans[0:len(tempTrans)-1]) !=-1:
		print "("+str(k)+","+tempTrans[0:len(tempTrans)-1]+")"
