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() ans := make([][]bool, pow(2, n)) var notAllOkFlg, notAllNgFlg bool for i := range ans { q := make([]int, n) for j := range q { q[j] = io.nextInt() } r := io.nextInt() if r == 1 { ans[i] = make([]bool, n) for j, v := range q { if v == 1 { ans[i][j] = true } } notAllNgFlg = true } else { notAllOkFlg = true } } io.print("A=") if !notAllNgFlg { io.println("⊥") } else if !notAllOkFlg { io.println("⊤") } else { flg := false for i := range ans { if ans[i] == nil { continue } if flg { io.print("∨") } io.print("(") for j, v := range ans[i] { if j != 0 { io.print("∧") } if !v { io.print("¬") } io.print("P_") io.print(j + 1) } io.print(")") flg = true } io.println() } } 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) print(a ...interface{}) { fmt.Fprint(_io.writer, a...) } func (_io *_io) println(a ...interface{}) { fmt.Fprintln(_io.writer, a...) }