P29738 [洛谷] "EVOI-RD2" Xin Xin's Inequality Group
普及
题目描述

Problem Description

Xin Xin is working on a math problem involving solving a system of linear inequalities with one variable.

This system consists of $n$ linear inequalities with one variable. She has determined the solution sets for each inequality individually, and she needs to combine them into the solution set for the entire system.

Each inequality's solution set is simplified to its simplest form, such as $x < t_i$ (or $x > t_i$, etc.), where $t_i$ is a constant and $x$ is the variable. The variable is a lowercase English letter and appears on the left side of the inequality; the constant is an integer and appears on the right side.

All inequalities use only the four inequality symbols $<, >, \le, \ge$. In the input and output of this problem, $\le$ and $\ge$ are represented by $<=$ and $>=$ respectively.

Xin Xin needs you to determine the solution set for this system of inequalities.

Input Format

The first line contains a positive integer $n$ and a lowercase English letter $x$, indicating that there are $n$ simplified inequality solution sets and the variable in the inequalities is $x$.

The next $n$ lines each contain a simplified linear inequality, representing the solution set of that inequality.

For each solution set, it is composed of the variable, an inequality symbol, and the constant term $t_i$, in that order, where the variable is the one given in the first line.

Output Format

Output one line, which is the solution set of the inequality system, in the form of "a op1 x op2 b" or "x op a", where op1 and op2 are $<$ or $<=$, and op is $<, <=, >, >=$ or $=$. Be careful not to include any extra spaces.

If the inequality system has no solution, output No Answer!.

Sample Input and Output

Sample Input #1

2 x
x>-3
x<=1

Sample Output #1

-3<x<=1

Sample Input #2

3 y
y>=5
y>4
y>=-2

Sample Output #2

y>=5

Sample Input #3

4 q
q>=114514
q>-200810
q<-1022
q<=-23333

Sample Output #3

No Answer!

Notes

[Sample 1 Explanation]

As shown in the number line, the common part of the solution sets of each inequality is the solution set of the inequality system, which is $-3 < x \le 1$. Note that $\le$ is replaced by $<=$ in the output.

[Data Range and Constraints]

This problem uses batched testing.

  • Subtask 1 (5 pts): $n = 1$.
  • Subtask 2 (25 pts): $n = 2$.
  • Subtask 3 (10 pts): $n \le 3$, $-4 \times 10^4 \le t_i \le 4 \times 10^4$.
  • Subtask 4 (20 pts): $n \le 10^4$, $-10^5 \le t_i \le 10^5$.
  • Subtask 5 (10 pts): $n \le 2 \times 10^4$.
  • Subtask 6 (20 pts): $n \le 5 \times 10^4$.
  • Subtask 7 (10 pts): No additional constraints.

For $100\%$ of the data, $1 \le n \le 6 \times 10^4$, $-10^6 \le t_i \le 10^6$, and the variable in each inequality is a lowercase English letter.

[Hints]

The following mathematical concepts are relevant to the problem:

  • Inequality: A relational expression connected by an inequality symbol.
  • Solution of an inequality: The values of the unknown that satisfy the inequality.
  • Solution set of an inequality: The set of all solutions to the inequality.
  • Solution set of an inequality system: The common part of the solution sets of all inequalities in the system.
  • Solving an inequality system: The process of finding the solution set of the inequality system.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 x x>-3 x<=1
样例输出
-3<x<=1