/* Alex Beutel * October 26, 2009 */ import java.util.*; public class ny09 { HashSet h = new HashSet(); public void getAll(String s, int count, int len) { if(s.length() == len*2) { if(count == 0) h.add(s); return; } if(count - 1 >= 0) getAll(s+")", count-1,len); getAll(s+"(", count+1,len); } public void printAll() { String[] s = h.toArray(new String[0]); for(int i = 0; i < s.length; i++) System.out.println(s[i]); } public static void main(String[] args) { ny09 n = new ny09(); int input = 3; //CHANGE INPUT VALUE HERE n.getAll("",0,input); n.printAll(); } }