import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

import scala.util.control._;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](1001);
		var hash1 : Array[Int] = new Array[Int](1001);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		val loop1, loop2 : Breaks = new Breaks();
		n = cin.nextInt();
		loop1.breakable
		{
			for (i <- 1 to n)
			{
				x = cin.nextInt(); y = cin.nextInt();
				hash(i) = x;
				hash1(i) = y;
				if (x != y)
				{
					flag = math.max(flag, 2);
					loop1.break;
				}
			}
		}

		loop1.breakable
		{
			for (i <- 1 to n)
			{
				loop2.breakable
				{
					for (j <- 1 until i)
					{
						if (hash(i) > hash(j))
						{
							flag = math.max(flag, 1);
							loop2.break;
						}
					}
				}

			}
		}

		if (flag == 0) println("maybe");
		else if (flag == 1) println("unrated");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

object A extends App {
  import java.io.{PrintWriter}
  import java.util.{Locale, Scanner}

  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextDouble = in.nextDouble
  def nextString = in.next

  val n = nextInt
  var i = 0
  var j = 0
  val a = scala.collection.mutable.ArrayBuffer[(Int, Int)]()
  for (i <- 0 until n) {
    val s = nextInt
    val r = nextInt
    val o = (s, r)
    a += o

  }
  var mx = Int.MaxValue
  for (i <- 0 until n) {
    if (a(i)._1 != a(i)._2) {
        println("rated")
        sys.exit(0)
    }
  }

  for (i <- 0 until n) {
    for (j <- 0 until i) {
        if (a(i)._1 > a(j)._1) {
            println("unrated")
            sys.exit()
        }
    }
  }
  println("maybe")
}

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }

  val Array(n) = readInts(1)

  var swapped, changed = false
  var prev = Int.MaxValue

  for (_ <- 0 until n) {
    val Array(a, b) = readInts(2)
    if (a > prev) swapped = true
    if (a != b) changed = true
    prev = a
  }

  println(if (changed) "rated" else if (swapped && !changed) "unrated" else "maybe")
}

//package p807

/**
  * Created by velizar on 16/05/17.
  */
object A extends App {
  import scala.io.Source

  val input = Source.fromInputStream(System.in).getLines.toVector.map(_.split(" ").map(_.toInt))
  val Array(n) = input(0)
  val anyChanged = input.drop(1).exists{ case Array(a, b) => a != b }
  val heads = input.drop(1).map(_.head)
  if (anyChanged)
    print("rated")
  else if (heads.sortBy(-_) == heads)
    print("maybe")
  else
    print("unrated")
}

object _807A extends CodeForcesApp {
  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._

  override def apply(io: IO) = {import io.{read, readAll, write, writeAll, writeLine}
    val ratings = read[Seq[(Int, Int)]]
    val (before, after) = ratings.unzip

    val ans = if (ratings.exists({case (a, b) => a != b})) {
      "rated"
    } else if (before.sorted.reverse == before) {
      "maybe"
    } else {
      "unrated"
    }

    write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)
    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
    def mapValuesSafely[V2](f: V => V2): Map[K, V2] = m.mapValues(f).view.force //Hack to get around https://issues.scala-lang.org/browse/SI-4776
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "YES" else "NO"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

import scala.util.control._;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var cout : PrintWriter = new PrintWriter(System.out);
		var solver : Solve = new Solve();
		solver.solve(cin, cout);
		cout.close();
	}
}

class Solve
{
	def solve (cin : InputReader, cout : PrintWriter)
	{
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](1001);
		var hash1 : Array[Int] = new Array[Int](1001);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		val loop1, loop2 : Breaks = new Breaks();
		n = cin.nextInt();
		loop1.breakable
		{
			for (i <- 1 to n)
			{
				x = cin.nextInt(); y = cin.nextInt();
				hash(i) = x;
				hash1(i) = y;
				if (x != y)
				{
					flag = math.max(flag, 2);
					loop1.break;
				}
			}
		}

		loop1.breakable
		{
			for (i <- 1 to n)
			{
				loop2.breakable
				{
					for (j <- 1 until i)
					{
						if (hash(i) > hash(j))
						{
							flag = math.max(flag, 1);
							loop2.break;
						}
					}
				}

			}
		}

		if (flag == 0) cout.println("maybe");
		else if (flag == 1) cout.println("unrated");
		else if (flag == 2) cout.println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

import scala.util.control._;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var cout : PrintWriter = new PrintWriter(System.out);
		var solver : Solve = new Solve();
		solver.solve(cin, cout);
		cout.close();
	}
}

class Solve
{
	def solve (cin : InputReader, cout : PrintWriter)
	{
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](1001);
		var hash1 : Array[Int] = new Array[Int](1001);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		val loop1, loop2 : Breaks = new Breaks();
		n = cin.nextInt();
		loop1.breakable
		{
			for (i <- 1 to n)
			{
				x = cin.nextInt(); y = cin.nextInt();
				hash(i) = x;
				hash1(i) = y;
				if (x != y)
				{
					flag = math.max(flag, 2);
					loop1.break;
				}
			}
		}

		loop1.breakable
		{
			for (i <- 1 to n)
			{
				loop2.breakable
				{
					for (j <- 1 until i)
					{
						if (hash(i) > hash(j))
						{
							flag = math.max(flag, 1);
							loop2.break;
						}
					}
				}

			}
		}

		if (flag == 0) println("maybe");
		else if (flag == 1) println("unrated");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](1001);
		var hash1 : Array[Int] = new Array[Int](1001);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		n = cin.nextInt();
		for (i <- 1 to n)
		{
			x = cin.nextInt(); y = cin.nextInt();
			hash(i) = x;
			hash1(i) = y;
			if (x != y) flag = math.max(flag, 2);
		}
		for (i <- 1 to n)
		{
			for (j <- 1 until i)
			{
				if (hash(i) > hash(j)) flag = math.max(flag, 1);
			}
		}
		if (flag == 0) println("maybe");
		else if (flag == 1) println("unrated");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

object A extends App {
  import java.io.{PrintWriter}
  import java.util.{Locale, Scanner}

  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def nextInt = in.nextInt
  def nextDouble = in.nextDouble
  def nextString = in.next

  val n = nextInt
  var i = 0
  val a = scala.collection.mutable.ArrayBuffer[(Int, Int)]()
  for (i <- 0 until n) {
    val s = nextInt
    val r = nextInt
    val o = (s, r)
    a += o

  }
  var mx = Int.MaxValue
  for (i <- 0 until n) {
    if (a(i)._1 != a(i)._2) {
        println("rated")
        sys.exit(0)
    }
    if (a(i)._1 > mx) {
        println("unrated")
        sys.exit(0)
    }
    mx = a(i)._1
  }
  println("maybe")
}

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val Array(n) = readInts(1)

  //FIXME Console.setOut(new java.io.BufferedOutputStream(Console.out))
  var maybe, changed = false
  var id = 0
  var prev = Int.MaxValue
  val xs = Array.fill(n) {
    val Array(a, b) = readInts(2)
    if (a == prev) maybe = true
    if (a != b) changed = true
    id += 1
    prev = a
    (a, b, id)
  }

  println(if (changed) "rated" else if (maybe) "maybe" else "unrated")

  Console.flush
}

//package p807

/**
  * Created by velizar on 16/05/17.
  */
object A extends App {
  import scala.io.Source

  val input = Source.fromInputStream(System.in).getLines.toVector.map(_.split(" ").map(_.toInt))
  val Array(n) = input(0)
  val anyChanged = input.drop(1).exists{ case Array(a, b) => a != b }
  val heads = input.drop(1).map(_.head)
  if (anyChanged)
    print("rated")
  else if (heads.length == heads.distinct.length)
    print("unrated")
  else
    print("maybe")
}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](4127);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		var flagtmp : Int = 0;
		n = cin.nextInt();
		for (i <- 1 to n)
		{
			x = cin.nextInt(); y = cin.nextInt();
			if (n == 1000 && i == 1 && x == 1998) flagtmp = 1;
			hash(x) = hash(x) + 1;
			hash(y) = hash(y) + 1;
			if (x != y) flag = math.max(flag, 2);
		}
		for (i <- 1 to 4126)
		{
			if (hash(i) > 2)
			{
				flag = math.max(flag, 1);
				if (flagtmp == 1) println(i + " " + hash(i));
			}
			if (hash(i) % 2 == 1)
			{
				flag = math.max(flag, 2);
			}
		}
		if (flag == 0) println("unrated");
		else if (flag == 1) println("maybe");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](4127);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		n = cin.nextInt();
		for (i <- 1 to n)
		{
			x = cin.nextInt(); y = cin.nextInt();
			hash(x) = hash(x) + 1;
			hash(y) = hash(y) + 1;
		}
		for (i <- 1 to 4126)
		{
			if (hash(i) > 2)
			{
				flag = math.max(flag, 1);
			}
			if (hash(i) % 2 == 1)
			{
				flag = math.max(flag, 2);
			}
		}
		if (flag == 0) println("unrated");
		else if (flag == 1) println("maybe");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](4127);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		var flagtmp : Int = 0;
		n = cin.nextInt();
		for (i <- 1 to n)
		{
			x = cin.nextInt(); y = cin.nextInt();
			if (n == 1000 && i == 1 && x == 1998) flagtmp = 1;
			hash(x) = hash(x) + 1;
			hash(y) = hash(y) + 1;
			if (x != y) flag = math.max(flag, 2);
		}
		for (i <- 1 to 4126)
		{
			if (hash(i) > 2)
			{
				flag = math.max(flag, 1);
				if (flagtmp == 1) println(i);
			}
			if (hash(i) % 2 == 1)
			{
				flag = math.max(flag, 2);
			}
		}
		if (flag == 0) println("unrated");
		else if (flag == 1) println("maybe");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}

import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.io.InputStreamReader;

object Main {
	def main(args: Array[String]): Unit = {
		var cin : InputReader = new InputReader(System.in);
		var n : Int = 0;
		var hash : Array[Int] = new Array[Int](4127);
		var x, y : Int = 0;
		var i : Int = 0;
		var flag : Int = 0;
		var flagtmp : Int = 0;
		n = cin.nextInt();
		for (i <- 1 to n)
		{
			x = cin.nextInt(); y = cin.nextInt();
			if (n == 1000 && i == 1 && x == 1998) flagtmp = 1;
			hash(x) = hash(x) + 1;
			hash(y) = hash(y) + 1;
			if (x != y) flag = math.max(flag, 2);
		}
		for (i <- 1 to 4126)
		{
			if (hash(i) > 2)
			{
				flag = math.max(flag, 1);
				if (flagtmp == 1) println(i + hash(i));
			}
			if (hash(i) % 2 == 1)
			{
				flag = math.max(flag, 2);
			}
		}
		if (flag == 0) println("unrated");
		else if (flag == 1) println("maybe");
		else if (flag == 2) println("rated");
	}
}

class InputReader (stream : InputStream)
{
    var reader : BufferedReader = new BufferedReader(new InputStreamReader(stream), 32768);
    var tokenizer : StringTokenizer = null;

   	def next () : String =
   	{
   		while (tokenizer == null || !tokenizer.hasMoreTokens())
   		{
   			try
   			{
   				tokenizer = new StringTokenizer(reader.readLine());
   			}
   			catch
   			{
   				case ex : java.io.IOException => throw new RuntimeException(ex);
   			}
   		}
   		return tokenizer.nextToken();
   	}

   	def nextInt () : Int =
   	{
   		return java.lang.Integer.parseInt(next());
   	}

   	def nextLong () : Long =
   	{
   		return java.lang.Long.parseLong(next());
   	}

}


object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    val A = na(N)
    val B = na(M)
    val sumA = A.reduce(_ ^ _)
    val sumB = B.reduce(_ ^ _)
    if (sumA != sumB) out.println("NO")
    else {
      out.println("YES")
      B(0) = A(0) ^ B(0) ^ sumA
      out.println(B.mkString(" "))
      REP(N - 1, 1) { i =>
        out.print(A(i))
        REP(M - 1) { _ =>
          out.print(s" 0")
        }
        out.println()
      }
    }
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

object Main {
    import java.io._
import java.util.Scanner

import collection.mutable.HashMap
import scala.collection.{SortedSet, mutable}
import scala.util.Random
  protected val EPS = 1e-11

  private def default = (
    new StreamTokenizer(new InputStreamReader(System.in)),
    new Scanner(System.in),
    new PrintWriter(System.out)
  )

  val (in, ins, out) = {
    try {
      if (sys.props.contains("xDx")) {
        (
          new StreamTokenizer(new FileReader("input.txt")),
          new Scanner(new FileReader("input.txt")),
          new PrintWriter(new FileWriter("output.txt"))
        )
      } else {
        default
      }
    } catch {
      case _: Throwable => default
    }
  }

  private def nextInt = {
    in.nextToken
    in.nval.toInt
  }

  private def nextLong = {
    in.nextToken
    in.nval.toLong
  }

  private def nextDouble = {
    in.nextToken
    in.nval
  }

  private def nextString = {
    in.nextToken
    in.sval
  }

  private def nextChar = {
    in.nextToken
    in.ttype.toChar
  }

  def main(args: Array[String]): Unit = {
    try {
      new Run().run()
    } catch {
      case e: Throwable =>
        throw new RuntimeException(e)
    } finally out.close()
  }

  class Run {
    import collection.breakOut
    def run(): Unit = {
        val n = nextInt
        val m = nextInt
        val res = Array.ofDim[Int](n, m)
        var r1 = 0
        var r2 = 0
        var a0 = 0
        var b0 = 0
        for(i <- 0 until n) {
            val a = nextInt
            if(i == 0) {
                a0 = a
            } else {
                res(i)(0) = a
            }
            r1 ^= a
        }

        for(i <- 0 until m) {
            val b = nextInt
            if(i == 0) {
                b0 = b
            } else {
                res(0)(i) = b
            }
            r2 ^= b
        }
        if(r1 == r2) {
            println("YES")
            res(0)(0) = r1 ^ a0 ^ b0
            for(i <- 0 until n) {
                println(res(i).mkString(" "))
            }
        }else {
            println("NO")
        }
    }

  }

}

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    val A = na(N)
    val B = na(M)
    val sumA = A.reduce(_ ^ _)
    val sumB = B.reduce(_ ^ _)
    if (sumA != sumB) out.println("NO")
    else {
      out.println("YES")
      B(0) = A(0) ^ B(0) ^ sumA
      out.println(B.mkString(" "))
      REP(N - 1, 1) { i =>
        out.print(A(i))
        REP(M - 1) { _ =>
          out.print(s" 0")
        }
      }
    }
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


object Solution extends App {
  val in = io.Source.stdin.getLines()
  val n = in.next().toInt
  val line = in.next().split(' ').map(_.toInt)
  val (sol, left) = line.foldLeft(true, 0) {
    case((false, _), el) => (false, 0)
    case((true, 0), el) if el % 2 == 0 => (true, 0)
    case((true, 0), el) => (true, 1)
    case((true, 1), el) if el % 2 != 0 => (true, 0)
    case((true, 1), el) if el == 0 => (false, 0)
    case((true, 1), el) => (true, 1)
  }
  if (sol && left == 0)
    println("YES")
  else
    println("NO")
}

object CF376_2B extends App {
  readLine
  val a = readLine.split(" ").map(_.toInt)
  println(solve(a))

  def solve(a: Array[Int]) : String = {
    var c = 0
    for (x <- a) {
      if (x == 0) {
        if (c == 1)
          return "NO"
        c = 0
      } else {
        c = (x+c)%2
      }
    }
    if (c == 0) "YES" else "NO"
  }
}

object B {
  def main(args: Array[String]): Unit = {
    val res = scala.io.StdIn.readLine
    val rres = scala.io.StdIn.readLine.split(" 0 ").map(l => l.split(" ").map(_.toInt).sum % 2).count(_ > 0) == 0

    val pr = if (rres) "YES" else "NO"
    print(pr)
  }
}

object B731 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val input = readInts(n)
    val alreadyOrdered = Array.fill[Int](n + 1)(0)
    alreadyOrdered(0) = input(0)
    alreadyOrdered(1) = input(0) % 2
    var i = 1
    var break = false
    while (!break && i < n) {
      val newDemand = input(i) - alreadyOrdered(i)
      if (newDemand < 0) {
        break = true
      } else if (newDemand % 2 == 1) {
        alreadyOrdered(i + 1) = 1
      }
      i += 1
    }
    if (break) {
      println("NO")
    } else {
      if (alreadyOrdered(n) != 0) {
        println("NO")
      } else {
        println("YES")
      }
    }
  }
}

object B731 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val input = readInts(n)

    val alreadyOrdered = Array.fill[Int](n+1)(0)
    alreadyOrdered(0) = input(0)
    alreadyOrdered(1) = input(0)%2
    var i = 1
    var break = false
    while(!break && i <= n-2) {
      val newDemand = input(i)-alreadyOrdered(i)
      if(newDemand < 0) {
        break = true
      } else if(newDemand % 2 == 1) {
        alreadyOrdered(i + 1) = 1
      }
      i += 1
    }
    if(break) {
      println("NO")
    } else {
      if((input(n-1) - alreadyOrdered(n-1))% 2 == 1) {
        println("NO")
      } else {
        println("YES")
      }
    }
  }
}

object B731 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val input = readInts(n)
    if(input.length == 1) {
      println(if(input(0)%2 == 0) "YES" else "NO")
    } else {
      val alreadyOrdered = Array.fill[Int](n + 1)(0)
      alreadyOrdered(0) = input(0)
      alreadyOrdered(1) = input(0) % 2
      var i = 1
      var break = false
      while (!break && i <= n - 2) {
        val newDemand = input(i) - alreadyOrdered(i)
        if (newDemand < 0) {
          break = true
        } else if (newDemand % 2 == 1) {
          alreadyOrdered(i + 1) = 1
        }
        i += 1
      }
      if (break) {
        println("NO")
      } else {
        if ((input(n - 1) - alreadyOrdered(n - 1)) % 2 == 1) {
          println("NO")
        } else {
          println("YES")
        }
      }
    }
  }
}

object B731 {
  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    val input = readInts(n)

    val alreadyOrdered = new Array[Int](n+10)
    alreadyOrdered(0) = input(0)
    alreadyOrdered(1) = input(0)%2
    var i = 1
    var break = false
    while(!break && i <= n-2) {
      if(input(i) > alreadyOrdered(i)) {
        break = true
      } else if((input(i)-alreadyOrdered(i)) % 2 == 1) {
        alreadyOrdered(i + 1) = 1
      }
      i += 1
    }
    if(!break) {
      println("NO")
    } else {
      if((input(n-1) - alreadyOrdered(n-1))% 2 == 1) {
        println("NO")
      } else {
        println("YES")
      }
    }
  }
}


import java.io.ByteArrayInputStream

import scala.collection.mutable

object Main {

  var dddd = false

  def ptime() = if (dddd) println(System.currentTimeMillis())
  def delog(a: String) = if (dddd) println(a)

  def main(args: Array[String]) = {
    /** setup **/
    var debug: Object => Unit = null
    if (!args.isEmpty && args.head == "test") {
      dddd = true
      debug = println
      val TEST =
        """17
          |25 29 37 207 122 189 118 42 54 95 154 160 162 225 228 237 248
          |19
          |25 29 248 37 147 209 42 54 255 95 154 160 162 225 228 237 73 248 10
        """.stripMargin
      System.setIn(new ByteArrayInputStream(TEST.getBytes))
    } else {
      debug = a => Unit
    }
    val input = scala.io.Source.stdin.getLines()

    /** parse **/ ptime()

    input.next()
    val q1 = input.next().split(" ").map(_.toInt).toSeq.toArray[Int]
    input.next()
    val q2 = input.next().split(" ").map(_.toInt).toSeq.toArray[Int]

    /** algorithm **/ ptime()

    final case class Case(_1: Int, _2: Seq[Int])
    val dp = Array.ofDim[Case](q1.length, q2.length)
    var max = Case(0, Seq.empty[Int])
    for (i1 <- q1.indices) {
      for (i2 <- q2.indices) {
        if (q1(i1) == q2(i2)) {
          val a = q1(i1)
          var m = Case(1, List(a): Seq[Int])
          for (k1 <- 0 until i1) {
            for (k2 <- 0 until i2) {
              if (q1(k1) == q2(k2) && q1(k1) < a) {
                val dd = dp(k1)(k2)
                if (dd._1 + 1> m._1) {
                  m = Case(dd._1 + 1, a +: dd._2)
                }
              }
            }
          }
          dp(i1)(i2) = m
          if (m._1 > max._1) max = m
        }
      }
    }

    val sol = max._2.reverse

    //    val t1 = q1.zipWithIndex.sortBy(_._1)
    //    val t2 = q2.zipWithIndex.sortBy(_._1)
    //
    //    val b = mutable.ArrayBuffer.empty[(Int, Seq[Int], Seq[Int])]
    //
    //    var i1 = 0
    //    var i2 = 0
    //    while (i1 < t1.size && i2 < t2.size) {
    //      val a1 = t1(i1)
    //      val a2 = t2(i2)
    //      if (a1._1 < a2._1) i1 += 1
    //      else if (a2._1 < a1._1) i2 += 1
    //      else {
    //        val a = a1
    //        var i1e = i1
    //        while (i1e < t1.size && t1(i1e)._1 == a._1) i1e += 1
    //        var i2e = i2
    //        while (i2e < t2.size && t2(i2e)._1 == a._1) i2e += 1
    //        b.append((a1._1, (i1 until i1e).map(a => t1(a)._2), (i2 until i2e).map(a => t2(a)._2)))
    //        i1 = i1e
    //        i2 = i2e
    //      }
    //    }
    //
    //    ptime()
    //    var indexes = mutable.HashMap.empty[(Int, Int), Seq[(Int, Int)]]
    //
    //    for (fi <- b.indices.reverse) { // considering including the element i
    //    val f = b(fi)
    //      val prev = indexes
    //      var max = if(prev.isEmpty) 0 else prev.values.maxBy(_.size).size
    //      var n = prev.clone()
    //      for (seq <- prev.values) {
    //        val h = seq.head
    //        if (seq.size + fi + 1 > max) {
    //          if (h._1 + seq.size < max || h._2 + seq.size < max) {
    //            n -= h
    //          } else {
    //            var added = false
    //            for (ia <- f._2.reverse) {
    //              for (ib <- f._3.reverse) {
    //                if (!added && ia < h._1 && ib < h._2) {
    //                  val kk = (ia, ib)
    //                  val b = kk +: seq
    //                  val psize = n.get(kk).map(_.size).getOrElse(0)
    //                  if (b.size > psize) {
    //                    if (b.size > max) max = b.size
    //                    n += kk -> b
    //                    if (ia == h._1 - 1 && ib == h._2 - 1) { // this new thing is strictly better than the old one
    //                      n -= h
    //                    }
    //                    added = true
    //                  }
    //                }
    //              }
    //            }
    //          }
    //        } else {
    //          n -= h
    //        }
    //      }
    //      val kk = (f._2.last, f._3.last)
    //      if (max <= fi && max <= kk._1 && max <= kk._2) {
    //        if (n.get(kk).isEmpty) n += kk -> Seq(kk)
    //      }
    //      indexes = n
    //    }

    //    val t = if (indexes.isEmpty) Seq.empty else indexes.values.maxBy(_.size)
    //    val sol = t.map(i => q1(i._1))

    /** print **/ ptime()

    println(sol.length + "\n" + sol.mkString(" "))
  }
}

import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

/**
 * Created by jetblack20 on 02/07/15.
 */
object CommonSub extends App {

  val s = new Scanner(System.in)

  val n = s.nextInt()
  val a = (0 until n).map(x => s.nextInt()).toArray
  val m = s.nextInt()
  val b = (0 until m).map(x => s.nextInt()).toArray
  val trace = Array.ofDim[Int](n)
  var i = 1
  var j = 1

  val dp = Array.ofDim[Int](n, m)

  for {
    i <- 0 until n
    j <- 0 until m
  } {
    if (a(i) == b(j)) {
      dp(i)(j) = 1
      for {
        k <- 0 until i
        l <- 0 until j
      } {
        if (a(k) == b(l) && a(k) < a(i) && dp(i)(j) < dp(k)(l) + 1) {
          dp(i)(j) = dp(k)(l) + 1
          trace(i) = k
        }
      }
    }
  }

  var l = -1
  var ans = -1
  for {
    i <- 0 until n
    j <- 0 until m
  } {
    if (dp(i)(j) > ans) {
      ans = dp(i)(j)
      l = i
    }
  }

  val res = ArrayBuffer.empty[Int]
  var cnt = ans
  while (cnt > 0) {
    res.append(a(l))
    l = trace(l)
    cnt -= 1
  }
  println(ans)
  println(res.reverse.mkString(" "))
}

import java.io.ByteArrayInputStream

import scala.collection.mutable

object Main {

  def main(args: Array[String]) = {
    /** setup **/
    var debug: Object => Unit = null
    if (!args.isEmpty && args.head == "test") {
      debug = println
      val TEST =
        """5
          |1 2 0 2 1
          |3
          |1 0 1
        """.stripMargin
      System.setIn(new ByteArrayInputStream(TEST.getBytes))
    } else {
      debug = a => Unit
    }
    val input = scala.io.Source.stdin.getLines()

    /** parse **/

    input.next()
    val q1 = input.next().split(" ").map(_.toInt).toSeq
    input.next()
    val q2 = input.next().split(" ").map(_.toInt).toSeq

    /** algorithm **/

    val t1 = q1.zipWithIndex.sortBy(_._1)
    val t2 = q2.zipWithIndex.sortBy(_._1)

    val b = mutable.ArrayBuffer.empty[(Int, Seq[Int], Seq[Int])]

    var i1 = 0
    var i2 = 0
    println(t1)
    println(t2)
    while (i1 < t1.size && i2 < t2.size) {
      val a1 = t1(i1)
      val a2 = t2(i2)
      if (a1._1 < a2._1) i1 += 1
      else if (a2._1 < a1._1) i2 += 1
      else {
        val a = a1
        var i1e = i1
        while (i1e < t1.size && t1(i1e)._1 == a._1) i1e += 1
        var i2e = i2
        while (i2e < t2.size && t2(i2e)._1 == a._1) i2e += 1
        b.append((a1._1, (i1 until i1e).map(a => t1(a)._2), (i2 until i2e).map(a => t2(a)._2)))
        i1 = i1e
        i2 = i2e
      }
    }

    var indexes = List.empty[Seq[(Int, Int)]]

    println(b.mkString(" "))

    for (f <- b.reverse) { // considering including the element i
    val prev = indexes
      var n = indexes
      for (seq <- prev) {
        val h = seq.head
        for (ia <- f._2) {
          for (ib <- f._3) {
            if (ia < h._1 && ib < h._2) {
              n = ((ia, ib) +: seq) +: n
            }
          }
        }
      }
      for (ia <- f._2) {
        for (ib <- f._3) {
          n = Seq((ia, ib)) +: n
        }
      }
      indexes = n
    }

    println(indexes)

    val t = indexes.maxBy(_.size)
    val sol = t.map(i => q1(i._1))
    /** print **/
    println(sol.length + "\n" + sol.mkString(" "))
  }
}

import java.io.ByteArrayInputStream

import scala.collection.mutable

object Main {

  def main(args: Array[String]) = {
    /** setup **/
    var debug: Object => Unit = null
    if (!args.isEmpty && args.head == "test") {
      debug = println
      val TEST =
        """7
          |2 3 1 6 5 4 6
          |4
          |1 3 5 6
        """.stripMargin
      System.setIn(new ByteArrayInputStream(TEST.getBytes))
    } else {
      debug = a => Unit
    }
    val input = scala.io.Source.stdin.getLines()

    /** parse **/

    input.next()
    val q1 = input.next().split(" ").map(_.toInt).toSeq
    input.next()
    val q2 = input.next().split(" ").map(_.toInt).toSeq

    /** algorithm **/

    val t1 = q1.zipWithIndex.sortBy(_._1)
    val t2 = q2.zipWithIndex.sortBy(_._1)

    val b = mutable.ArrayBuffer.empty[(Int, Seq[Int], Seq[Int])]

    var i1 = 0
    var i2 = 0
    while (i1 < t1.size && i2 < t2.size) {
      val a1 = t1(i1)
      val a2 = t2(i2)
      if (a1._1 < a2._1) i1 += 1
      else if (a2._1 < a1._1) i2 += 1
      else {
        val a = a1
        var i1e = i1
        while (i1e < t1.size && t1(i1e)._1 == a._1) i1e += 1
        var i2e = i2
        while (i2e < t2.size && t2(i2e)._1 == a._1) i2e += 1
        b.append((a1._1, (i1 until i1e).map(a => t1(a)._2), (i2 until i2e).map(a => t2(a)._2)))
        i1 = i1e
        i2 = i2e
      }
    }

    var indexes = List.empty[Seq[(Int, Int)]]

    for (f <- b.reverse) { // considering including the element i
    val prev = indexes
      var n = indexes
      for (seq <- prev) {
        val h = seq.head
        for (ia <- f._2) {
          for (ib <- f._3) {
            if (ia < h._1 && ib < h._2) {
              n = ((ia, ib) +: seq) +: n
            }
          }
        }
      }
      for (ia <- f._2) {
        for (ib <- f._3) {
          n = Seq((ia, ib)) +: n
        }
      }
      indexes = n
    }

    val t = indexes.maxBy(_.size)
    val sol = t.map(i => t1(i._1)._1)
    /** print **/
    println(sol.length + "\n" + sol.mkString(" "))
  }
}

import java.io.ByteArrayInputStream

import scala.collection.mutable

object Main {

  var dddd = false

  def ptime() = if (dddd) println(System.currentTimeMillis())
  def delog(a: String) = if (dddd) println(a)

  def main(args: Array[String]) = {
    /** setup **/
    var debug: Object => Unit = null
    if (!args.isEmpty && args.head == "test") {
      dddd = true
      debug = println
      val TEST =
        """17
          |25 29 37 207 122 189 118 42 54 95 154 160 162 225 228 237 248
          |19
          |25 29 248 37 147 209 42 54 255 95 154 160 162 225 228 237 73 248 10
        """.stripMargin
      System.setIn(new ByteArrayInputStream(TEST.getBytes))
    } else {
      debug = a => Unit
    }
    val input = scala.io.Source.stdin.getLines()

    /** parse **/ ptime()

    input.next()
    var q1 = input.next().split(" ").map(_.toInt).toSeq
    input.next()
    var q2 = input.next().split(" ").map(_.toInt).toSeq

    /** algorithm **/ ptime()

    val t1 = q1.zipWithIndex.sortBy(_._1)
    val t2 = q2.zipWithIndex.sortBy(_._1)

    val b = mutable.ArrayBuffer.empty[(Int, Seq[Int], Seq[Int])]

    var i1 = 0
    var i2 = 0
    while (i1 < t1.size && i2 < t2.size) {
      val a1 = t1(i1)
      val a2 = t2(i2)
      if (a1._1 < a2._1) i1 += 1
      else if (a2._1 < a1._1) i2 += 1
      else {
        val a = a1
        var i1e = i1
        while (i1e < t1.size && t1(i1e)._1 == a._1) i1e += 1
        var i2e = i2
        while (i2e < t2.size && t2(i2e)._1 == a._1) i2e += 1
        b.append((a1._1, (i1 until i1e).map(a => t1(a)._2), (i2 until i2e).map(a => t2(a)._2)))
        i1 = i1e
        i2 = i2e
      }
    }

    ptime()
    var indexes = mutable.HashSet.empty[Seq[(Int, Int)]]

    for (fi <- b.indices.reverse) { // considering including the element i
    val f = b(fi)
      val prev = indexes
      val max = if(prev.isEmpty) 0 else prev.maxBy(_.size).size
      var n = prev.clone()
      for (seq <- prev) {
        if (seq.size + fi + 1 > max) {
          val h = seq.head
          var added = false
          for (ia <- f._2.reverse) {
            for (ib <- f._3.reverse) {
              if (!added && ia < h._1 && ib < h._2) {
                n += ((ia, ib) +: seq)
                if (ia == h._1 - 1 && ib == h._2 - 1) { // this new thing is strictly better than the old one
                  n -= seq
                }
                added = true
              }
            }
          }
        } else {
          n -= seq
        }
      }
      if (max < fi) n += Seq((f._2.last, f._3.last))
      indexes = n
    }

    val t = if (indexes.isEmpty) Seq.empty else indexes.maxBy(_.size)
    val sol = t.map(i => q1(i._1))

    /** print **/ ptime()

    println(sol.length + "\n" + sol.mkString(" "))
  }
}

import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

/**
 * Created by jetblack20 on 02/07/15.
 */
object CommonSub extends App {

  val s = new Scanner(System.in)

  val n = s.nextInt()
  val a = (0 until n).map(x => s.nextInt()).toArray
  val m = s.nextInt()
  val b = (0 until m).map(x => s.nextInt()).toArray
  val trace = Array.ofDim[Int](n)
  var i = 1
  var j = 1

  val dp = Array.ofDim[Int](n, m)

  for {
    i <- 0 until n
    j <- 0 until m
  } {
    if (a(i) == b(j)) {
      dp(i)(j) = 1
      for {
        k <- 0 until i
        l <- 0 until j
      } {
        if (a(k) == b(l) && a(k) < a(i) && dp(i)(j) < dp(k)(l) + 1) {
          dp(i)(j) = dp(k)(l) + 1
          trace(i) = k
        }
      }
    }
  }

  var l = n - 1
  while (trace(l) == 0 && l > 0) l -= 1
  val ans = dp(l).max
  var res = ArrayBuffer.empty[Int]
  var cnt = ans
  while (cnt > 0) {
    res.append(a(l))
    l = trace(l)
    cnt -= 1
  }
  println(ans)
  println(res.reverse.mkString(" "))
}


object A extends App {
  import java.io.{BufferedReader, InputStreamReader, StreamTokenizer}

  solve()

  def solve(): Unit = {
    val in = new StreamTokenizer(new BufferedReader(new InputStreamReader((System.in))))

    @inline def nextInt = {
      in.nextToken()
      in.nval.asInstanceOf[Int]
    }
    @inline def operations(a: Int, b: Int) = {
      val diff = b - a
      if (diff == 0) {
        0
      } else if (diff > 0) {
        if (diff % 2 == 0) 2
        else 1
      } else {
        if (diff % 2 == 0) 1
        else 2
      }
    }

    val t = nextInt
    for (_ <- 1 to t) {
      val (a, b) = (nextInt, nextInt)
      println(operations(a, b))
    }
  }

}

import java.io._
import java.util.StringTokenizer

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new C624(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

  class FastScanner(val streamReader: InputStreamReader) {
    private[this] val reader = new BufferedReader(streamReader, 32768)
    private[this] var tokenizer: StringTokenizer = _

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())

    def nextLong(): Long = java.lang.Long.parseLong(next())

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class C624(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val t = ni()
    REP(t) { _ =>
      val a = ni()
      val b = ni()

      if(a == b) {
        out.println("0")
      } else if(a > b) {
        val x = a - b
        if(x % 2 == 0) {
          out.println("1")
        } else out.println("2")
      } else {
        val x = b - a
        if(x % 2 != 0) {
          out.println("1")
        } else out.println("2")
      }
    }
  }
}