object Main {
    def main(args: Array[String]): Unit = {
      val lines = io.Source.stdin.getLines().toSeq
      println(solve(lines))
    }

    def solve(lines: Seq[String]): String = {
      val s = lines.head.split("").filter(_.length > 0).take(4)
      debug(s)

      val left = s.slice(0, 2).mkString("").toInt
      val right = s.slice(2, s.length).mkString("").toInt
      debug(left, right)

      val isLeftMonth = isMonth(left)
      val isRightMonth = isMonth(right)

      var ans = ""
      if (isLeftMonth != isRightMonth) {
        ans = if (isLeftMonth) "MMYY" else "YYMM"
      } else if (!isLeftMonth && !isRightMonth) {
        ans = "NA"
      } else {
        ans = "AMBIGUOUS"
      }
      ans
    }

    def isMonth(n: Int): Boolean = {
      n >= 1 && n <= 12
    }

    private def debug(x: Any): Unit = {
      if (System.getenv("LOCAL_DEBUG") != null) println(x)
    }
  }