#!/usr/bin/env python
import sys
import commands

input = [ "%1%2%3", "%1%2", "%1%2%3%4", "%3%2%1", "%2%1", "%4%3%2%1" ]
output = [ "abc", "ab", "abc%4", "cba", "ba", "%4cba" ]

for i in range(len(output)):
  cmd = "./arg " + input[i] + " a b c"
  result = commands.getoutput(cmd)
  print cmd + " = " + result
  if result != output[i]:
    sys.exit(1)
