Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use.In this problem we consider the following model of #define constructions (also called macros). Each macro has its name and value. The generic syntax for declaring a macro is the following:#define macro_name macro_valueAfter the macro has been declared, "macro_name" is replaced with "macro_value" each time it is met in the program (only the whole tokens can be replaced; i.e. "macro_name" is replaced only when it is surrounded by spaces or other non-alphabetic symbol). A "macro_value" within our model can only be an arithmetic expression consisting of variables, four arithmetic operations, brackets, and also the names of previously declared macros (in this case replacement is performed sequentially). The process of replacing macros with their values is called substitution.One of the main problems arising while using macros — the situation when as a result of substitution we get an arithmetic expression with the changed order of calculation because of different priorities of the operations.Let's consider the following example. Say, we declared such a #define construction:#define sum x + yand further in the program the expression "2 * sum" is calculated. After macro substitution is performed we get "2 * x + y", instead of intuitively expected "2 * (x + y)".Let's call the situation "suspicious", if after the macro substitution the order of calculation changes, falling outside the bounds of some macro. Thus, your task is to find out by the given set of #define definitions and the given expression if this expression is suspicious or not.Let's speak more formally. We should perform an ordinary macros substitution in the given expression. Moreover, we should perform a "safe" macros substitution in the expression, putting in brackets each macro value; after this, guided by arithmetic rules of brackets expansion, we can omit some of the brackets. If there exist a way to get an expression, absolutely coinciding with the expression that is the result of an ordinary substitution (character-by-character, but ignoring spaces), then this expression and the macros system are called correct, otherwise — suspicious.Note that we consider the "/" operation as the usual mathematical division, not the integer division like in C/C++. That's why, for example, in the expression "a*(b/c)" we can omit brackets to get the expression "a*b/c".

The first line contains the only number n (0 ≤ n ≤ 100) — the amount of #define constructions in the given program. Then there follow n lines, each of them contains just one #define construction. Each construction has the following syntax: #define name expression where   name — the macro name,  expression — the expression with which the given macro will be replaced. An expression is a non-empty string, containing digits,names of variables, names of previously declared macros, round brackets and operational signs +-*/. It is guaranteed that the expression (before and after macros substitution) is a correct arithmetic expression, having no unary operations. The expression contains only non-negative integers, not exceeding 109.  All the names (#define constructions' names and names of their arguments) are strings of case-sensitive Latin characters. It is guaranteed that the name of any variable is different from any #define construction. Then, the last line contains an expression that you are to check. This expression is non-empty and satisfies the same limitations as the expressions in #define constructions. The input lines may contain any number of spaces anywhere, providing these spaces do not break the word "define" or the names of constructions and variables. In particular, there can be any number of spaces before and after the "#" symbol. The length of any line from the input file does not exceed 100 characters.

Output "OK", if the expression is correct according to the above given criterion, otherwise output "Suspicious".

4
#define sum  x + y
#define mul  a * b
#define div  a / b
#define expr sum + mul * div * mul
expr

3
#define SumSafe   (a+b)
#define DivUnsafe  a/b
#define DenominatorUnsafe  a*b
((SumSafe) + DivUnsafe/DivUnsafe + x/DenominatorUnsafe)

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getOp(tokens []string) string {

	if len(tokens) == 1 {
		rank, ok := macro2Op[tokens[0]]
		if ok {
			return rank
		} else {
			return "()"
		}
	}

	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					break
				}
			}
			rank, ok := macro2Op[num[numPointer-1]]
			if ok && rank == "fail" {
				return rank
			} else {
				num[numPointer-1] = "1"
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		s, _ := reader.ReadString('\n')

		s = strings.TrimLeft(s, " #")
		s = strings.TrimPrefix(s, "define")
		s = strings.TrimLeft(s, " ")
		fmt.Sscanf(s, "%s", &macro)
		s = strings.TrimPrefix(s, macro)
		tokens := tokenize(s)
		macro2Op[macro] = getOp(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getOp(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {
	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	rank, ok := macro2Op[num[numPointer-1]]
	if ok {
		return rank
	}
	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {

	if len(tokens) == 1 {
		rank, ok := macro2Op[tokens[0]]
		if ok {
			return rank
		} else {
			return "()"
		}
	}

	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && op1 == "-") || (op == "/" && op1 == "/") ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {
	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}
	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}

}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {

	if len(tokens) == 1 {
		rank, ok := macro2Op[tokens[0]]
		if ok {
			return rank
		} else {
			return "()"
		}
	}

	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			rank, ok := macro2Op[num[numPointer-1]]
			if ok && rank == "fail" {
				return rank
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && op1 == "-") || (op == "/" && op1 == "/") ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {
	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}
	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}

}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getOp(tokens []string) string {

	if len(tokens) == 1 {
		rank, ok := macro2Op[tokens[0]]
		if ok {
			return rank
		} else {
			return "()"
		}
	}

	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					break
				}
			}
			rank, ok := macro2Op[num[numPointer-1]]
			if ok && rank == "fail" {
				return rank
			} else {
				num[numPointer-1] = "1"
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		s, _ := reader.ReadString('\n')

		s = strings.TrimLeft(s, " #")
		s = strings.TrimPrefix(s, "define")
		s = strings.TrimLeft(s, " ")
		fmt.Sscanf(s, "%s", &macro)
		s = strings.TrimPrefix(s, macro)

		fmt.Printf("macro:%s expr:%s\n", macro, s)
		tokens := tokenize(s)
		macro2Op[macro] = getOp(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getOp(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {
	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}
	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {

	if len(tokens) == 1 {
		rank, ok := macro2Op[tokens[0]]
		if ok {
			return rank
		} else {
			return "()"
		}
	}

	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					break
				}
			}
			rank, ok := macro2Op[num[numPointer-1]]
			if ok && rank == "fail" {
				return rank
			} else {
				num[numPointer-1] = "1"
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}

package main

import (
	"bytes"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
)

var macro2Op map[string]string

func check(num0, num1, op string) error {
	op0, ok0 := macro2Op[num0]
	op1, ok1 := macro2Op[num1]

	if ok0 {
		if op0 == "fail" {
			return errors.New("fail")
		}
		if (op == "*" || op == "/") && (op0 == "+" || op0 == "-") {
			return errors.New("fail")
		}
	}

	if ok1 {
		if op1 == "fail" {
			return errors.New("fail")
		}
		if (op == "-" && (op1 == "-" || op1 == "+")) || (op == "/" && (op1 == "/" || op1 == "*")) ||
			((op == "*" || op == "/") && (op1 == "+" || op1 == "-")) {
			return errors.New("fail")
		}
	}
	return nil
}

func getRank(tokens []string) string {
	op := make([]string, 10000, 10000)
	num := make([]string, 10000, 10000)
	opPointer, numPointer := 0, 0
	ret := ""

	for i := 0; i < len(tokens); i++ {
		if tokens[i] == "(" {
			op[opPointer] = "("
			opPointer++
		} else if tokens[i] == "+" || tokens[i] == "-" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == "*" || tokens[i] == "/" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					ret = op[opPointer-1]
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else {
					break
				}
			}
			op[opPointer] = tokens[i]
			opPointer++
		} else if tokens[i] == ")" {
			for opPointer != 0 {
				if op[opPointer-1] == "*" || op[opPointer-1] == "/" || op[opPointer-1] == "+" || op[opPointer-1] == "-" {
					err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
					if err != nil {
						return "fail"
					}
					numPointer--
					num[numPointer-1] = "1"
					opPointer--
				} else if op[opPointer-1] == "(" {
					opPointer--
					num[numPointer-1] = "1"
					break
				}
			}
			ret = "()"
		} else {
			num[numPointer] = tokens[i]
			numPointer++
		}
	}
	for opPointer != 0 {
		err := check(num[numPointer-2], num[numPointer-1], op[opPointer-1])
		if err != nil {
			return "fail"
		}
		ret = op[opPointer-1]
		numPointer--
		num[numPointer-1] = "1"
		opPointer--
	}

	rank, ok := macro2Op[num[numPointer-1]]
	if ok {
		return rank
	}
	return ret
}

func tokenize(s string) []string {
	tokens := make([]string, 0, 200)
	b := []byte(s)
	token := make([]byte, 0, 100)
	for i := 0; i < len(b); i++ {
		if b[i] == '(' || b[i] == ')' ||
			b[i] == '+' || b[i] == '-' || b[i] == '*' || b[i] == '/' ||
			b[i] == '\r' || b[i] == '\n' || b[i] == ' ' {
			if len(token) != 0 {
				tokens = append(tokens, string(token))
				token = make([]byte, 0, 100)
			}
			if b[i] != ' ' && b[i] != '\r' && b[i] != '\n' {
				tokens = append(tokens, string([]byte{b[i]}))
			}
		} else {
			token = append(token, b[i])
		}
	}
	return tokens
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	macro2Op = map[string]string{}

	for i := 0; i < n; i++ {
		var macro string
		fmt.Fscanf(reader, "#define %s ", &macro)
		s, _ := reader.ReadString('\n')
		tokens := tokenize(s)
		macro2Op[macro] = getRank(tokens)
	}

	testexpr, _ := ioutil.ReadAll(reader)
	expr := string(testexpr) + "\n"
	ts := tokenize(expr)
	rank := getRank(ts)
	if rank == "fail" {
		fmt.Printf("Suspicious")
	} else {
		fmt.Printf("OK")
	}
}


You got a job as a marketer in a pet shop, and your current task is to boost sales of cat food. One of the strategies is to sell cans of food in packs with discounts. Suppose you decided to sell packs with $$$a$$$ cans in a pack with a discount and some customer wants to buy $$$x$$$ cans of cat food. Then he follows a greedy strategy:   he buys $$$\left\lfloor \frac{x}{a} \right\rfloor$$$ packs with a discount;  then he wants to buy the remaining $$$(x \bmod a)$$$ cans one by one. $$$\left\lfloor \frac{x}{a} \right\rfloor$$$ is $$$x$$$ divided by $$$a$$$ rounded down, $$$x \bmod a$$$ is the remainer of $$$x$$$ divided by $$$a$$$.But customers are greedy in general, so if the customer wants to buy $$$(x \bmod a)$$$ cans one by one and it happens that $$$(x \bmod a) \ge \frac{a}{2}$$$ he decides to buy the whole pack of $$$a$$$ cans (instead of buying $$$(x \bmod a)$$$ cans). It makes you, as a marketer, happy since the customer bought more than he wanted initially.You know that each of the customers that come to your shop can buy any number of cans from $$$l$$$ to $$$r$$$ inclusive. Can you choose such size of pack $$$a$$$ that each customer buys more cans than they wanted initially?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first and only line of each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l \le r \le 10^9$$$) — the range of the number of cans customers can buy.

For each test case, print YES if you can choose such size of pack $$$a$$$ that each customer buys more cans than they wanted initially. Otherwise, print NO. You can print each character in any case.

NoteIn the first test case, you can take, for example, $$$a = 5$$$ as the size of the pack. Then if a customer wants to buy $$$3$$$ cans, he'll buy $$$5$$$ instead ($$$3 \bmod 5 = 3$$$, $$$\frac{5}{2} = 2.5$$$). The one who wants $$$4$$$ cans will also buy $$$5$$$ cans.In the second test case, there is no way to choose $$$a$$$.In the third test case, you can take, for example, $$$a = 80$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	t int16
	l int32
	r int32
	a int32
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &l, &r)

		fmt.Println(check(l, r))
	}

}

func check(l int32, r int32) string {
	flag := false

	if l >= (r+2)/2 {
		flag = true
	}

	if flag {
		return "YES"
	} else {
		return "NO"
	}
}

package main

import (
	"fmt"
	"bufio"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func solve() {
	var l, r int
	scanf("%d %d\n", &l, &r)
	ans := "NO"
	if 2 * l >= r + 1 {
		ans = "YES"
	}
	printf("%s\n", ans)
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func min_int(a int, b int) int { if a < b { return a } else { return b } }
func min_int64(a int64, b int64) int64 { if a < b { return a } else { return b } }

func max_int(a int, b int) int { if a > b { return a } else { return b } }
func max_int64(a int64, b int64) int64 { if a > b { return a } else { return b } }

func main() {
	defer writer.Flush()

	var T int = 0
	scanf("%d\n", &T)

	for t := 0; t < T; t++ {

		var l, r int64
		scanf("%d %d\n", &l, &r)

		var a int64 = r + 1

		var l_left_side float64 = float64(l % a)
		var l_right_side float64 = float64(float64(a)/2.0)

		var r_left_side float64 = float64(r % a)
		var r_right_side = float64(float64(a)/2.0)

		// printf("%f\n", float64(l)/float64(a))
		// printf("%f %f\n", l_left_side, l_right_side)

		if l_left_side >= l_right_side && r_left_side >= r_right_side {
			printf("YES\n")
		} else {
			printf("NO\n")
		}

	}

}

// Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools

package main

import (
	"fmt"
)

func main() {
	// Write your solution here
	var t int
	fmt.Scanf("%d\n", &t)
	for ;t>0; t-- {
		var l, r int
		fmt.Scanf("%d %d\n", &l, &r)

		minA := 2*(r-l)+1
		maxA := 2*l
		if minA<=maxA {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1437A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, l, r int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &l, &r)
		if l >= r/2+1 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1437A(os.Stdin, os.Stdout) }

package main
import "fmt"
func main() {
	q := 0
	fmt.Scan(&q)
	for t := 0; t < q; t++ {
		var l, r int
		fmt.Scan(&l, &r)
		if 2 * l > r {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	io := bufio.NewReader(os.Stdin)
	var t, l, r int
	fmt.Fscan(io, &t)
	for ; t > 0; t-- {
		fmt.Fscan(io, &l, &r)
		if r/l < 2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d\n", &l, &r)

		if (2*(r-l) + 1) <= 2*l {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d\n", &l, &r)

		minA := 2*(r-l) + 1
		if minA <= 2*l {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

import (
	"bufio"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func print(str string) {
	writer.WriteString(str)
}

func nextInt() int {
	scanner.Scan()
	str := scanner.Text()
	val, _ := strconv.Atoi(str)
	return val
}

func nextFloat() float64 {
	scanner.Scan()
	str := scanner.Text()
	val, _ := strconv.ParseFloat(str, 64)
	return val
}

func nextString() string {
	scanner.Scan()
	str := scanner.Text()
	return str
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer writer.Flush()

	t := nextInt()
	for t != 0 {
		L := nextInt()
		R := nextInt()
		if L >= (R + 1 + 1) / 2 {
			print("yes\n")
		} else {
			print("no\n")
		}
		t--
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	t int16
	l int32
	r int32
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &l, &r)

		fmt.Println(check(l, r))
	}

}

func check(l int32, r int32) string {
	flag := false

	if l < 1 {
		a := l - 1

		if l%a >= a/2.0 && r%a > a/2.0 {
			flag = true
		}
	}

	a := r + 1

	if l%a > a/2 && r%a > a/2 {
		flag = true
	}

	if flag {
		return "YES"
	} else {
		return "NO"
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	t int16
	l int32
	r int32
	a int32
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &l, &r)

		fmt.Println(check(l, r))
	}

}

func check(l int32, r int32) string {
	flag := false

	if l > 1 {
		a = l - 1

		if float32(l%a) >= float32(a)/2 && float32(r%a) >= float32(a)/2 {
			flag = true
		}
	}

	a = r + 1

	//fmt.Println(a, l%a, float32(a)/2, r%a)

	if float32(l%a) >= float32(a)/2 && float32(r%a) >= float32(a)/2 {
		flag = true
	}

	if flag {
		return "YES"
	} else {
		return "NO"
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	t int16
	l int32
	r int32
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

	for ; t > 0; t-- {
		fmt.Fscan(reader, &l, &r)

		fmt.Println(check(l, r))
	}

}

func check(l int32, r int32) string {
	flag := false

	if l < 1 {
		a := l - 1

		if l%a >= a/2.0 && r%a >= a/2.0 {
			flag = true
		}
	}

	a := r + 1

	if l%a >= a/2 && r%a >= a/2 {
		flag = true
	}

	if flag {
		return "YES"
	} else {
		return "NO"
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1437A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, l, r int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &l, &r)
		if l >= (r+1)/2 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

func main() { CF1437A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	io := bufio.NewReader(os.Stdin)
	var t, l, r int
	fmt.Fscan(io, &t)
	for ; t > 0; t-- {
		fmt.Fscan(io, &l, &r)
		if r/l < 2 {
			fmt.Print("YES")
		} else {
			fmt.Print("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d", &l, &r)

		if (2*(r-l) + 1) <= 2*l {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d", l, r)

		if l*2 > r {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d", &l, &r)

		if l*2 > r {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}

package main

import "fmt"

func main() {
	var t, l, r int

	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {

		fmt.Scanf("%d %d\n", &l, &r)

		if (2*(r-l) + 1) <= 2*l {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}
}


DZY loves Physics, and he enjoys calculating density.Almost everything has density, even a graph. We define the density of a non-directed graph (nodes and edges of the graph have some values) as follows:  where v is the sum of the values of the nodes, e is the sum of the values of the edges.Once DZY got a graph G, now he wants to find a connected induced subgraph G' of the graph, such that the density of G' is as large as possible.An induced subgraph G'(V', E') of a graph G(V, E) is a graph that satisfies:  ;  edge  if and only if , and edge ;  the value of an edge in G' is the same as the value of the corresponding edge in G, so as the value of a node. Help DZY to find the induced subgraph with maximum density. Note that the induced subgraph you choose must be connected.

The first line contains two space-separated integers n (1 ≤ n ≤ 500), . Integer n represents the number of nodes of the graph G, m represents the number of edges. The second line contains n space-separated integers xi (1 ≤ xi ≤ 106), where xi represents the value of the i-th node. Consider the graph nodes are numbered from 1 to n. Each of the next m lines contains three space-separated integers ai, bi, ci (1 ≤ ai < bi ≤ n; 1 ≤ ci ≤ 103), denoting an edge between node ai and bi with value ci. The graph won't contain multiple edges.

Output a real number denoting the answer, with an absolute or relative error of at most 10 - 9.

NoteIn the first sample, you can only choose an empty subgraph, or the subgraph containing only node 1.In the second sample, choosing the whole graph is optimal.

package main

import (
  "bufio"
  "fmt"
  "os"
)

const NUM_VERTEX = 500

var vertex_value [NUM_VERTEX]int

func main() {
  reader := bufio.NewReader(os.Stdin)
  var n, m int
  fmt.Fscan(reader, &n, &m)
  for i := 0; i < n; i++ {
    fmt.Fscan(reader, &vertex_value[i])
  }
  var density float64 = 0
  for i := 0; i < m; i++ {
    var a, b, c int
    fmt.Fscan(reader, &a, &b, &c)
    a--
    b--
    new_density := float64(vertex_value[a]+vertex_value[b]) / float64(c)
    if new_density > density {
      density = new_density
    }
  }
  fmt.Printf("%.9f\n", density)
}

package main

import (
	"fmt"
	"os"
	"bufio"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(r, &n, &m)

	vs := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &vs[i])
	}

	var best float64
	for i := 0; i < m; i++ {
		var v0, v1 int
		var c float64
		fmt.Fscan(r, &v0, &v1, &c)

		w := (vs[v0-1]+vs[v1-1])/c
		if w > best {
			best = w
		}
	}
	fmt.Println(best)
}

package main

import (
	"fmt"
	"sort"
)

const (
	tresh = 1000
)

var (
	x int64
	as []int
	bs []int
)

func getNextX() int {
    x = (x * 37 + 10007) % 1000000007
    return int(x)
}

type Indicies []int
func (a Indicies) Len() int           { return len(a) }
func (a Indicies) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Indicies) Less(i, j int) bool { return as[a[i]] > as[a[j]] }

func main() {
	var n, d int
	fmt.Scan(&n, &d, &x)

	as = make([]int, n)
	bs = make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = i+1
		if i < d {
			bs[i] = 1
		}
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		as[i], as[j] = as[j], as[i]
	}
	for i := 0; i < n; i++ {
		j := getNextX() % (i + 1)
		bs[i], bs[j] = bs[j], bs[i]
	}

	if d < tresh {
		cs := make([]int, n)
		for i := 0; i < n; i++ {
			if bs[i] == 1 {
				for j := i; j < n; j++ {
					if cs[j] < as[j-i] {
						cs[j] = as[j-i]
					}
				}
			}
		}
		for _, c := range cs {
			fmt.Println(c)
		}
	} else {
		var ordered Indicies = make([]int, n)
		for i := 0; i < n; i++ {
			ordered[i] = i
		}
		sort.Sort(ordered)
		for j := 0; j < n; j++ {
			for _, i := range ordered {
				if j-i >= 0 && bs[j-i] == 1 {
					fmt.Println(as[i])
					break
				}
			}
		}
	}
}


After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.At the start of the day they have x ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the night. Each person in the queue wants either to take several ice cream packs for himself and his friends or to give several ice cream packs to Kay and Gerda (carriers that bring ice cream have to stand in the same queue).If a carrier with d ice cream packs comes to the house, then Kay and Gerda take all his packs. If a child who wants to take d ice cream packs comes to the house, then Kay and Gerda will give him d packs if they have enough ice cream, otherwise the child will get no ice cream at all and will leave in distress.Kay wants to find the amount of ice cream they will have after all people will leave from the queue, and Gerda wants to find the number of distressed kids.

The first line contains two space-separated integers n and x (1 ≤ n ≤ 1000, 0 ≤ x ≤ 109). Each of the next n lines contains a character '+' or '-', and an integer di, separated by a space (1 ≤ di ≤ 109). Record "+ di" in i-th line means that a carrier with di ice cream packs occupies i-th place from the start of the queue, and record "- di" means that a child who wants to take di packs stands in i-th place.

Print two space-separated integers — number of ice cream packs left after all operations, and number of kids that left the house in distress.

NoteConsider the first sample.  Initially Kay and Gerda have 7 packs of ice cream.  Carrier brings 5 more, so now they have 12 packs.  A kid asks for 10 packs and receives them. There are only 2 packs remaining.  Another kid asks for 20 packs. Kay and Gerda do not have them, so the kid goes away distressed.  Carrier bring 40 packs, now Kay and Gerda have 42 packs.  Kid asks for 20 packs and receives them. There are 22 packs remaining.

package main

import "fmt"

func main() {
	var x int64
	var n, notSatisfied int
	fmt.Scan(&n, &x)
	for i := 0; i<n; i++ {
		var sign string
		var amount int64
		fmt.Scan(&sign, &amount)
		if sign == "+" {
			x += amount
		} else if x >= amount {
			x -= amount
		} else {
			notSatisfied++
		}
	}
	fmt.Println(x, notSatisfied)
}

package main

import "fmt"

func main() {
	var n, iceCreams, i int64
	fmt.Scanf("%d %d\n", &n, &iceCreams)
	var distress int64
	for i = 0; i < n; i++ {
		var sign string
		var value int64
		fmt.Scanf("%s %d\n", &sign, &value)
		if sign == "+" {
			iceCreams += value
		} else {
			if iceCreams >= value {
				iceCreams -= value
			} else {
				distress += 1
			}
		}

	}
	fmt.Print(iceCreams)
	fmt.Print(" ")
	fmt.Println(distress)

}

package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
	"strconv"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10000000)
	var n, x int
	fmt.Scanf("%d %d\n", &n, &x)
	var sum int64
	sum = int64(x)
	sad := 0
	for i:=0; i< n; i++{
		bytes, _ ,_ := reader.ReadLine()
		strs := strings.Split(string(bytes), " ")
		v, _ := strconv.Atoi(strs[1])
		if strs[0] == "-" {
			v = -v
		}
		if sum + int64(v) < 0 {
			sad ++
		} else {
			sum += int64(v)
		}
	}
	fmt.Printf("%d %d",sum , sad)
}

package main
import (
	"fmt"
)

func main(){
	var n int
	var c string
	var d,di int64
	fmt.Scan(&n)
	fmt.Scan(&d)
	var sum int64 = d
	var counter int64 = 0
 	for i:=0; i < n; i++{
		fmt.Scan(&c)
		fmt.Scan(&di)

		if c == "+"{
			sum += di
		}else{
			if di <= sum{
				sum -= di
			}else{
				counter++
			}
		}
	}
	output := fmt.Sprintf("%v %v",sum,counter)
	fmt.Println(output)
}

package main

import "fmt"

func main() {
	var n, x, k int64
	fmt.Scan(&n, &x)
	for i := int64(1); i <= n; i++ {
		var s string
		var xi int64
		fmt.Scan(&s, &xi)
		if s == "+" {
			x += xi
		} else {
			if x < xi {
				k++
			} else {
				x -= xi
			}
		}
	}
	fmt.Printf("%d %d\n", x, k)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n, gon uint16
	var x, z uint64
	var o string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &x)
	for i := uint16(0); i < n; i++ {
		fmt.Fscanf(in, "%s %d\n", &o, &z)
		if string(o) == "+" {
			x += z
		} else {
			if z <= x {
				x -= z
			} else {
				gon++
			}
		}
	}
	fmt.Println(x, gon)
}

package main

import "fmt"

func main() {
	var n, m, x, i, cnt int64
	fmt.Scan(&n, &m)
	var s string
	for i = 0; i < n; i++ {
		fmt.Scan(&s, &x)
		if s == "+" {
			m += x
		} else if s == "-" && m-x >= 0 {
			m -= x
		} else {
			cnt++
		}
	}
	fmt.Print(m, " ", cnt)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var x int64
	fmt.Scan(&n, &x)

	var distress int = 0
	for i:= 0; i < n; i++ {
		var s string
		var amount int64
		fmt.Scan(&s, &amount)
		if strings.Compare(s, "-") == 0 {
			if amount <= x {
				x -= amount
				//fmt.Println("min")
			} else {
				distress++
				//fmt.Println("distress")
			}
		} else {
			x += amount
			//fmt.Println("Add")
		}
	}
	fmt.Printf("%d %d", x, distress)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var stockPacks, packs, distressChilds int64
	var operations int
	var currentOpertaion string
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &operations)
	fmt.Fscan(reader, &stockPacks)
	for index := 0; index < operations; index++ {
		fmt.Fscan(reader, &currentOpertaion)
		fmt.Fscan(reader, &packs)
		if currentOpertaion == "+" {
			stockPacks += packs
		} else if currentOpertaion == "-" {
			if packs > stockPacks {
				distressChilds++
			} else {
				stockPacks -= packs
			}
		}

	}
	fmt.Println(stockPacks, distressChilds)
}

package main

import "fmt"

func main(){
	var n int
	var x int64
	fmt.Scan(&n, &x)

	var op string
	var d int64
	var ans = 0
	for i := 0; i < n; i++{
		fmt.Scan(&op, &d)
		if op == "+"{
			x += d;
		}else {
			if x >= d {

				x -= d
			}else {
				ans++
			}
		}
	}
	fmt.Println(x, ans)
}

package main

import "fmt"
import "bufio"
import "os"
import "strings"
import "strconv"

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	var x int64
	x, _ = strconv.ParseInt(s[1], 10, 64)
	var d int64
	d = 0
	for scanner.Scan() {
		s := strings.Split(scanner.Text(), " ")
		v, _ := strconv.ParseInt(s[1], 10, 64)
		if s[0] == "-" {
			if v > x {
				d += 1
			} else {
				x -= v
			}
		} else {
			x += v
		}

	}
	fmt.Printf("%d %d", x, d)
}

package main

import "fmt"

func main() {
	var x int64
	var n, notSatisfied int
	fmt.Scan(&n, &x)
	for i := 0; i<n; i++ {
		var sign string
		var amount int64
		fmt.Scanf("%s %v\n", &sign, &amount)
		if sign == "+" {
			x += amount
		} else if x >= amount {
			x -= amount
		} else {
			notSatisfied++
		}
	}
	fmt.Println(x, notSatisfied)
}

package main

import "fmt"

func main() {
	var n, iceCreams int
	fmt.Scanf("%d %d\n", &n, &iceCreams)
	var distress int
	for i := 0; i < n; i++ {
		var sign string
		var value int
		fmt.Scanf("%s %d\n", &sign, &value)
		if sign == "+" {
			iceCreams += value
		} else {
			if iceCreams >= value {
				iceCreams -= value
			} else {
				distress += 1
			}
		}

	}
	fmt.Print(iceCreams)
	fmt.Print(" ")
	fmt.Println(distress)

}

package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
	"strconv"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10000000)
	var n, x int
	fmt.Scanf("%d %d\n", &n, &x)
	var sum int64
	sum = int64(x)
	sad := 0
	for i:=0; i< n; i++{
		bytes, _ ,_ := reader.ReadLine()
		strs := strings.Split(string(bytes), " ")
		v, _ := strconv.Atoi(strs[1])
		if strs[0] == "-" {
			v = -v
		}
		if sum + int64(v) < 0 {
			sad ++
		} else {
			sum += int64(v)
		}
	}
	fmt.Printf("%d %d",x , sad)
}

package main

import (
	"bufio"
	"os"
	"fmt"
	"strings"
	"strconv"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10000000)
	var n, x int
	fmt.Scanf("%d %d\n", &n, &x)
	sad := 0
	for i:=0; i< n; i++{
		bytes, _ ,_ := reader.ReadLine()
		strs := strings.Split(string(bytes), " ")
		v, _ := strconv.Atoi(strs[1])
		if strs[0] == "-" {
			v = -v
		}
		if x + v < 0 {
			sad ++
		} else {
			x += v
		}
	}
	fmt.Printf("%d %d",x , sad)
}

package main

import "fmt"

func main() {
	var n, x, k int64
	fmt.Scanf("%d %d", &n, &x)
	for i := int64(1); i <= n; i++ {
		var s string
		var xi int64
		fmt.Scanf("%s %d", &s, &xi)
		if s == "+" {
			x += xi
		} else {
			if x < xi {
				k++
			} else {
				x -= xi
			}
		}
	}
	fmt.Printf("%d %d\n", x, k)
}

package main

import "fmt"

func main() {
	var n, x, k int64
	fmt.Scanf("%d %d", &n, &x)
	for i := int64(1); i <= n; i++ {
		var s string
		var xi int64
		fmt.Scanf("%s %d", s, &xi)
		if s == "+" {
			x += xi
		} else {
			if x < xi {
				k++
			} else {
				x -= xi
			}
		}
	}
	fmt.Printf("%d %d\n", x, k)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var n, gon uint16
	var x, z uint32
	var o string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d\n", &n, &x)
	for i := uint16(0); i < n; i++ {
		fmt.Fscanf(in, "%s %d\n", &o, &z)
		if string(o) == "+" {
			x += z
		} else {
			if z <= x {
				x -= z
			} else {
				gon++
			}
		}
	}
	fmt.Println(x, gon)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, x int
	fmt.Scanf("%d%d", &n, &x)

	var distress int = 0
	for i:= 0; i < n; i++ {
		var s string
		var amount int
		fmt.Scanf("%s%d", &s, &amount)
		if strings.Compare(s, "-") == 0 {
			if amount <= x {
				x -= amount
				//fmt.Println("min")
			} else {
				distress++
				//fmt.Println("distress")
			}
		} else {
			x += amount
			//fmt.Println("Add")
		}
	}
	fmt.Printf("%d %d", x, distress)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	var distress int = 0
	for i:= 0; i < n; i++ {
		var s string
		var amount int
		fmt.Scan(&s, &amount)
		if strings.Compare(s, "-") == 0 {
			if amount <= x {
				x -= amount
				//fmt.Println("min")
			} else {
				distress++
				//fmt.Println("distress")
			}
		} else {
			x += amount
			//fmt.Println("Add")
		}
	}
	fmt.Printf("%d %d", x, distress)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var operations, stockPacks, packs, distressChilds int
	var currentOpertaion string
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &operations)
	fmt.Fscan(reader, &stockPacks)
	for index := 0; index < operations; index++ {
		fmt.Fscan(reader, &currentOpertaion)
		fmt.Fscan(reader, &packs)
		if currentOpertaion == "+" {
			stockPacks += packs
		} else if currentOpertaion == "-" {
			if packs > stockPacks {
				distressChilds++
			} else {
				stockPacks -= packs
			}
		}

	}
	fmt.Println(stockPacks, distressChilds)
}

package main

import "fmt"

func main(){
	var n, x int
	fmt.Scan(&n, &x)

	var op string
	var d int
	var ans = 0
	for i := 0; i < n; i++{
		fmt.Scan(&op, &d)
		if op == "+"{
			x += d;
		}else {
			if x >= d {

				x -= d
			}else {
				ans++
			}
		}
	}
	fmt.Println(x, ans)
}

package main

import "fmt"
import "bufio"
import "os"
import "strings"
import "strconv"

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	x, _ := strconv.Atoi(s[1])
	d := 0
	for scanner.Scan() {
		s := strings.Split(scanner.Text(), " ")
		v, _ := strconv.Atoi(s[1])
		if s[0] == "-" {
			if v > x {
				d += 1
			} else {
				x -= v
			}
		} else {
			x += v
		}

	}
	fmt.Printf("%d %d", x, d)
}


Ilya has recently taken up archaeology. He's recently found two numbers, written in the m-based notation. Each of the found numbers consisted of exactly n digits. Ilya immediately started looking for information about those numbers. He learned that the numbers are part of a cyphered code and the one who can decypher it can get the greatest treasure.After considerable research Ilya understood that to decypher the code, he should do the following:  Rearrange digits in the first number in some manner. Similarly, rearrange digits in the second number in some manner. As a result of this operation, the numbers can get leading zeroes.  Add numbers, digit by digit, modulo m. In other words, we need to get the third number of length n, each digit of the number is the sum of the respective numbers of the found numbers. For example, suppose there are two numbers recorded in the ternary notation, 001210 and 012111, then if you add them to each other digit by digit modulo 3, you will get number 010021.  The key to the code is the maximum possible number that can be obtained in the previous step. Help Ilya, find the key to the code.

The first line contains two integers n, m (1 ≤ n, m ≤ 105, m > 1). The second line contains the first found number, the third line contains the second found number.  The numbers are recorded as a sequence of digits in the m-based notation. Each digit is an integer from 0 to m - 1. The digits in the line are written in the order from the most significant digits to the least significant ones. The given numbers can contain leading zeroes.

Print n m-base digits. The resulting third number written in the m-based notation. Print the digits in the order from the most significant digits to the least significant ones.

package main

import (
	"bufio"
	"os"
	"sort"
	"strconv"
	"strings"
)

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func readInts() []int {
	line, _ := in.ReadString('\n')
	words := strings.Fields(line)
	a := make([]int, len(words))
	for i, v := range words {
		a[i], _ = strconv.Atoi(v)
	}
	return a
}

func main() {
	m := readInts()[1]
	a := make([]int, m)
	b := make([]int, m)
	var q, r, ans []int
	for _, v := range readInts() {
		a[v]++
	}
	for _, v := range readInts() {
		b[v]++
	}
	for x := m - 1; x >= 0; x-- {
		for ; b[m-1-x] > 0; b[m-1-x]-- {
			q = append(q, m-1-x)
		}
		for ; a[x] > 0; a[x]-- {
			if len(q) > 0 {
				ans = append(ans, -(q[len(q)-1] + x))
				q = q[:len(q)-1]
			} else {
				r = append(r, x)
			}
		}
	}
	for _, v := range r {
		ans = append(ans, -(q[len(q)-1] + v - m))
		q = q[:len(q)-1]
	}
	sort.Ints(ans)
	for _, v := range ans {
		out.WriteString(strconv.Itoa(-v))
		out.WriteByte(' ')
	}
	out.WriteByte('\n')
	out.Flush()
}


You are given $$$n$$$ points on the plane. The polygon formed from all the $$$n$$$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $$$1$$$ to $$$n$$$, in clockwise order.We define the distance between two points $$$p_1 = (x_1, y_1)$$$ and $$$p_2 = (x_2, y_2)$$$ as their Manhattan distance: $$$$$$d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|.$$$$$$Furthermore, we define the perimeter of a polygon, as the sum of Manhattan distances between all adjacent pairs of points on it; if the points on the polygon are ordered as $$$p_1, p_2, \ldots, p_k$$$ $$$(k \geq 3)$$$, then the perimeter of the polygon is $$$d(p_1, p_2) + d(p_2, p_3) + \ldots + d(p_k, p_1)$$$.For some parameter $$$k$$$, let's consider all the polygons that can be formed from the given set of points, having any $$$k$$$ vertices, such that the polygon is not self-intersecting. For each such polygon, let's consider its perimeter. Over all such perimeters, we define $$$f(k)$$$ to be the maximal perimeter.Please note, when checking whether a polygon is self-intersecting, that the edges of a polygon are still drawn as straight lines. For instance, in the following pictures:  In the middle polygon, the order of points ($$$p_1, p_3, p_2, p_4$$$) is not valid, since it is a self-intersecting polygon. The right polygon (whose edges resemble the Manhattan distance) has the same order and is not self-intersecting, but we consider edges as straight lines. The correct way to draw this polygon is ($$$p_1, p_2, p_3, p_4$$$), which is the left polygon.Your task is to compute $$$f(3), f(4), \ldots, f(n)$$$. In other words, find the maximum possible perimeter for each possible number of points (i.e. $$$3$$$ to $$$n$$$).

The first line contains a single integer $$$n$$$ ($$$3 \leq n \leq 3\cdot 10^5$$$) — the number of points.  Each of the next $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$-10^8 \leq x_i, y_i \leq 10^8$$$) — the coordinates of point $$$p_i$$$. The set of points is guaranteed to be convex, all points are distinct, the points are ordered in clockwise order, and there will be no three collinear points.

NoteIn the first example, for $$$f(3)$$$, we consider four possible polygons:   ($$$p_1, p_2, p_3$$$), with perimeter $$$12$$$.  ($$$p_1, p_2, p_4$$$), with perimeter $$$8$$$.  ($$$p_1, p_3, p_4$$$), with perimeter $$$12$$$.  ($$$p_2, p_3, p_4$$$), with perimeter $$$12$$$. For $$$f(4)$$$, there is only one option, taking all the given points. Its perimeter $$$14$$$.In the second example, there is only one possible polygon. Its perimeter is $$$8$$$.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	min = int(-1e8)
	max = int(1e8)
)

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

type point struct {
	x, y int
}

func minMax(ps []point) (mi, ma point) {
	mi.x = max
	mi.y = max
	ma.x = min
	ma.y = min
	for _, p := range ps {
		if mi.x > p.x {
			mi.x = p.x
		}
		if mi.y > p.y {
			mi.y = p.y
		}
		if ma.x < p.x {
			ma.x = p.x
		}
		if ma.y < p.y {
			ma.y = p.y
		}
	}
	return
}

func per(p ...point) int {
	mi, ma := minMax(p)
	return 2 * ((ma.x - mi.x) + (ma.y - mi.y))
}

func main() {
	var n int
	fmt.Fscan(in, &n)
	points := make([]point, n)
	for i := range points {
		fmt.Fscan(in, &points[i].x, &points[i].y)
	}

	mi, ma := minMax(points)
	var candidates []point
	for _, p := range points {
		if p.x == mi.x || p.x == ma.x || p.y == mi.y || p.y == ma.y {
			candidates = append(candidates, p)
		}
	}

	best := 0
	for _, p := range points {
		for i, q := range candidates {
			for _, r := range candidates[i+1:] {
				if cur := per(p, q, r); best < cur {
					best = cur
				}
			}
		}
	}

	fmt.Print(best)
	fmt.Println(strings.Repeat(" "+strconv.Itoa(per(candidates...)), n-3))
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	min = int(-1e8)
	max = int(1e8)
)

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func per(xy ...[2]int) int {
	minX := max
	minY := max
	maxX := min
	maxY := min
	for _, xy := range xy {
		if minX > xy[0] {
			minX = xy[0]
		}
		if minY > xy[1] {
			minY = xy[1]
		}
		if maxX < xy[0] {
			maxX = xy[0]
		}
		if maxY < xy[1] {
			maxY = xy[1]
		}
	}
	return 2 * ((maxX - minX) + (maxY - minY))
}

const magic = 50

func main() {
	var n int
	fmt.Fscan(in, &n)
	xy := make([][2]int, n)
	for i := range xy {
		fmt.Fscan(in, &xy[i][0], &xy[i][1])
	}

	j := 1
	k := 2
	best := 0
	for i := 0; i < n; i++ {
		if i < j && i + magic >= j || i > j && j+n-i <= magic || n < magic+10 {
			j = (i+1)%n
		} else {
			j = (j - magic + n) % n
		}
		if j < k && j + magic >= k || j > k && k+n-j <= magic || n < magic+10 {
			k = (j+1)%n
		} else {
			k = (k - magic + n) % n
		}
		for (j+1)%n != i {
			for per(xy[i], xy[j], xy[k]) < per(xy[i], xy[j], xy[(k+1)%n]) {
				k = (k + 1) % n
			}
			if per(xy[i], xy[j], xy[k]) < per(xy[i], xy[(j+1)%n], xy[k]) {
				j = (j + 1) % n
			} else {
				break
			}
		}
		if cur := per(xy[i], xy[j], xy[k]); best < cur {
			best = cur
		}
	}
	fmt.Print(best)
	fmt.Println(strings.Repeat(" "+strconv.Itoa(per(xy...)), n-3))
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const (
	min = int(-1e8)
	max = int(1e8)
)

var in = bufio.NewReaderSize(os.Stdin, 2<<16)

func per(xy ...[2]int) int {
	minX := max
	minY := max
	maxX := min
	maxY := min
	for _, xy := range xy {
		if minX > xy[0] {
			minX = xy[0]
		}
		if minY > xy[1] {
			minY = xy[1]
		}
		if maxX < xy[0] {
			maxX = xy[0]
		}
		if maxY < xy[1] {
			maxY = xy[1]
		}
	}
	return 2 * ((maxX - minX) + (maxY - minY))
}

func main() {
	var n int
	fmt.Fscan(in, &n)
	xy := make([][2]int, n)
	for i := range xy {
		fmt.Fscan(in, &xy[i][0], &xy[i][1])
	}

	j := 1
	k := 2
	best := 0
	for i := 0; i < n; i++ {
		for (j+1)%n != i {
			for per(xy[i], xy[j], xy[k]) < per(xy[i], xy[j], xy[(k+1)%n]) {
				k = (k + 1) % n
			}
			if per(xy[i], xy[j], xy[k]) < per(xy[i], xy[(j+1)%n], xy[k]) {
				j = (j + 1) % n
			} else {
				break
			}
		}
		if cur := per(xy[i], xy[j], xy[k]); best < cur {
			best = cur
		}
	}
	fmt.Print(best)
	fmt.Println(strings.Repeat(" "+strconv.Itoa(per(xy...)), n-3))
}


Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.The classroom contains $$$n$$$ rows of seats and there are $$$m$$$ seats in each row. Then the classroom can be represented as an $$$n \times m$$$ matrix. The character '.' represents an empty seat, while '*' means that the seat is occupied. You need to find $$$k$$$ consecutive empty seats in the same row or column and arrange those seats for you and your friends. Your task is to find the number of ways to arrange the seats. Two ways are considered different if sets of places that students occupy differs.

The first line contains three positive integers $$$n,m,k$$$ ($$$1 \leq n, m, k \leq 2\,000$$$), where $$$n,m$$$ represent the sizes of the classroom and $$$k$$$ is the number of consecutive seats you need to find. Each of the next $$$n$$$ lines contains $$$m$$$ characters '.' or '*'. They form a matrix representing the classroom, '.' denotes an empty seat, and '*' denotes an occupied seat.

A single number, denoting the number of ways to find $$$k$$$ empty seats in the same row or column.

NoteIn the first sample, there are three ways to arrange those seats. You can take the following seats for your arrangement.   $$$(1,3)$$$, $$$(2,3)$$$  $$$(2,2)$$$, $$$(2,3)$$$  $$$(2,1)$$$, $$$(2,2)$$$

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, M, K := sc.NextInt(), sc.NextInt(), sc.NextInt()
	matrix := make([][]byte, N)
	for i := 0; i < N; i++ {
		matrix[i] = []byte(sc.NextLine())
	}
	ans := 0
	for i := 0; i < N; i++ {
		cnt := 0
		for j := 0; j < M; j++ {
			if matrix[i][j] == '.' {
				cnt++
				if cnt >= K {
					ans++
				}
			} else {
				cnt = 0
			}
		}
	}
	if K > 1 {

		for i := 0; i < M; i++ {
			cnt := 0
			for j := 0; j < N; j++ {
				if matrix[j][i] == '.' {
					cnt++
					if cnt >= K {
						ans++
					}
				} else {
					cnt = 0
				}
			}
		}
	}
	fmt.Println(ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


There is a rectangular grid of n rows of m initially-white cells each.Arkady performed a certain number (possibly zero) of operations on it. In the i-th operation, a non-empty subset of rows Ri and a non-empty subset of columns Ci are chosen. For each row r in Ri and each column c in Ci, the intersection of row r and column c is coloured black.There's another constraint: a row or a column can only be chosen at most once among all operations. In other words, it means that no pair of (i, j) (i < j) exists such that  or , where  denotes intersection of sets, and  denotes the empty set.You are to determine whether a valid sequence of operations exists that produces a given final grid.

The first line contains two space-separated integers n and m (1 ≤ n, m ≤ 50) — the number of rows and columns of the grid, respectively. Each of the following n lines contains a string of m characters, each being either '.' (denoting a white cell) or '#' (denoting a black cell), representing the desired setup.

If the given grid can be achieved by any valid sequence of operations, output "Yes"; otherwise output "No" (both without quotes). You can print each character in any case (upper or lower).

NoteFor the first example, the desired setup can be produced by 3 operations, as is shown below.  For the second example, the desired setup cannot be produced, since in order to colour the center row, the third row and all columns must be selected in one operation, but after that no column can be selected again, hence it won't be possible to colour the other cells in the center column.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	matrix := make([][]byte, N)
	for i := 0; i < N; i++ {
		matrix[i] = []byte(sc.NextLine())
	}

	types := make([][]int, 0)

	checked := map[int]int{}

	for i := 0; i < N; i++ {
		tmp := make([]int, 0)
		for j := 0; j < M; j++ {
			if matrix[i][j] == '#' {
				tmp = append(tmp, j)
				if v, ok := checked[j]; ok {
					if v != tmp[0] {
						fmt.Println("No")
						return
					}
				}
				checked[j] = tmp[0]

			}
		}
		if len(tmp) > 0 {
			for _, p := range types {
				if p[0] == tmp[0] {
					if len(p) == len(tmp) {
						for k := 0; k < len(p); k++ {
							if p[k] != tmp[k] {
								fmt.Println("No")
								return
							}
						}
					} else {
						fmt.Println("No")
						return

					}
				}
			}
			types = append(types, tmp)
		}
	}
	fmt.Println("Yes")
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, M := sc.NextInt(), sc.NextInt()
	matrix := make([][]byte, N)
	for i := 0; i < N; i++ {
		matrix[i] = []byte(sc.NextLine())
	}

	types := make([][]int, 0)

	checked := map[int]int{}

	for i := 0; i < N; i++ {
		tmp := make([]int, 0)
		for j := 0; j < M; j++ {
			if matrix[i][j] == '#' {
				tmp = append(tmp, j)
				if v, ok := checked[j]; ok {
					if v != tmp[0] {
						fmt.Println("No")
						return
					}
				}
				checked[j] = tmp[0]

			}
		}
		if len(tmp) > 0 {
			for _, p := range types {
				if p[0] == tmp[0] && len(p) == len(tmp) {
					for k := 0; k < len(p); k++ {
						if p[k] != tmp[k] {
							fmt.Println("No")
							return
						}
					}
				}
			}
			types = append(types, tmp)
		}
	}
	fmt.Println("Yes")
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}