package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func pow(a, b int) int { res := 1 for range make([]struct{}, b) { res *= a } return res } func main() { io := newIo() defer io.flush() n := io.nextInt() flg := false ans := "" for range make([]struct{}, pow(2, n)) { q := make([]int, n) for j := range q { q[j] = io.nextInt() } r := io.nextInt() if r == 1 { if ans != "" { ans += "∨" } ans += "(" for j, v := range q { if j != 0 { ans += "∧" } if v == 0 { ans += "¬" } ans += "P_" + strconv.Itoa(j+1) } ans += ")" } else { flg = true } } if ans == "" { ans = "⊥" } else if !flg { ans = "⊤" } io.printf("A=%s\n", ans) } type _io struct { reader *bufio.Reader writer *bufio.Writer tokens []string nextToken int } func newIo() *_io { return &_io{ reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout), } } func (_io *_io) flush() { _ = _io.writer.Flush() } func (_io *_io) nextLine() string { var buffer []byte for { line, isPrefix, _ := _io.reader.ReadLine() buffer = append(buffer, line...) if !isPrefix { break } } return string(buffer) } func (_io *_io) next() string { for _io.nextToken >= len(_io.tokens) { line := _io.nextLine() _io.tokens = strings.Fields(line) _io.nextToken = 0 } r := _io.tokens[_io.nextToken] _io.nextToken++ return r } func (_io *_io) nextInt() int { i, _ := strconv.Atoi(_io.next()) return i } func (_io *_io) printf(format string, a ...interface{}) { fmt.Fprintf(_io.writer, format, a...) }