#! /usr/bin/python
import sys
import re
import random
import time
import os
from os.path import join
import time

# This is a quick hack for ACSD06+ATPN06 tutorial demo.
# It prints out a run of a Petri net out of a model given
# by bczchaff, bcminisat, or bcsat.

def replace(line,pattern,replacement):
    pat = re.compile(pattern)
    line = pat.sub(replacement,line)
    return line

lines = sys.stdin.readlines()

if(len(lines) > 0):

    line = lines[-1]
    line = replace(line,"\n","")

    pat = re.compile("Solution: (.*)")
    m = pat.match(line)
    if (not m):
	pat = re.compile("Satisfiable(.*)")
	m = pat.match(line)
	if(m):
	    line = lines[-2]
	    line = replace(line,"\n","")
	    solution = line
	else:
	    sys.exit(1)
    else:
	solution = m.group(1)

    lits = re.split(" ", solution)
	
    poslits = []
    for l in lits:
	if((l[0:1] == "p") or (l[0:1] == "t")):
	    poslits.append(l)

    poslits.sort()
#    print poslits
    output = ""
    match = -1
    i = 0
#   Quick hack, fixme: Prints only the first 500 steps of a cex
    while(i < 500):
	    
	pat = re.compile("p(.*)_%d$" % (i))

	match1 = 0
	marking = "{"
	for l in poslits:
	    m = pat.match(l)
	    if(m):
		match1 = 1
		marking = marking + "p%s, " % m.group(1)

	if(match1 != 0):
	    marking = marking[:-2] + "}"
	    if(match == 0):
		output = output + "[>"		
	    output = output + marking

	pat = re.compile("t(.*)_%d$" % (i))

	match = 0
	step = "["
	for l in poslits:
	    m = pat.match(l)
	    if(m):
		match = 1
		step = step + "t%s, " % m.group(1)

	if(match != 0):
	    step = step[:-2] + ">"
	    output = output + step

	i = i + 1


    print output
