#!/usr/local/bin/perl -w

use strict;

my($pairs) = shift or die "Must specify number of pairs.\n";

my %str = ('' => 1);

foreach (1 .. $pairs) {
  foreach my $str (keys %str) {
    foreach (0 .. length $str) {
      my $tmp = $str;
      substr($tmp, $_, 0) = "()";
      $str{$tmp} = 1;
    }
    delete $str{$str};
  }
}

print "$_\n" for sort keys %str;

