<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pair(args):
 """ %prog pair samfile Parses the sam file and retrieve in pairs format, query:pos ref:pos """

    p = OptionParser(pair.__doc__)

    opts, args = p.parse_args(args)
    if len(args) != 1:
        sys.exit(p.print_help())

    def callback(s):
        print(s.pairline)
    Sam(args[0], callback=callback)