jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include <stdio.h>

int main()
{
	int n,q; scanf("%d %d",&n,&q);
	char s[n]; scanf("%s",s);
	int counter[n-1];
	for (int i = 0; i < n-1; ++i)
	{
		if(s[i]=='A'&&s[i+1]=='C'){
			counter[i]=1;
		}else{
			counter[i]=0;
		}
	}

	int l[q],r[q];
	int ans=0; 
	for (int i = 0; i < q; ++i)
	{
		scanf("%d %d",&l[i],&r[i]);
		l[i]--; r[i]--;
		for (int j = l[i]; j < r[i]; ++j)
		{
			ans+=counter[j];
		}
		printf("%d\n",ans);
		ans=0;
	}

	return 0;
}
//  [c]
#include<stdio.h>


int main(){
    int N;
    int Q;
    scanf("%d",&N);
    scanf("%d",&Q);
    char S[100001];
    scanf("%s",S);
    int l[Q];
    int r[Q];
    for(int i=0;i<Q;i++){
        scanf("%d",&l[i]);
        scanf("%d",&r[i]);
    }
    int num[100001]={};
    for(int i=0;i<N;i++){
        if(S[i]=='A'&&S[i+1]=='C'){
                num[i]++;
                i++;
            }
    }
    
    int max = 0;
    for(int i=0;i<N;i++){
            max += num[i];
    }
    
    
    
    
    
    
    
    for(int i=0;i<Q;i++){    
        
        int counter=0;
        if(r[i]-l[i]<N/2)
        for(int j=l[i];j<r[i];j++){
            counter += num[j-1];
        }
        else {
            counter = max;
            for(int j=1;j<l[i];j++){
                counter -=num[j-1];
            }
            for(int j=r[i];j<=N;j++){
                counter -=num[j-1];
            }
        }
        
        
        printf("%d",counter);
        printf("\n");
    }

    return 0;







}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define REP(i,n) for(i=0;i<n;i++)
#define REVREP(i,n) for(i=n-1;i>=0;i--)

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

void check(char *S, int *C) {
    int i, j;
    REVREP(i,strlen(S)) {
        j = i + 1;
        if (j > strlen(S)) continue;
//        cout(S[i]);
        if (S[i] != 'A') {
            C[i] += C[j];
        } else {
            if (S[j] != 'C') {
                C[i] += C[j];
            } else {
                C[i] += (C[j] + 1);
            }
        }
    }
}

int main() {
    int N = iin(), Q = iin();
    char S[N];
    int C[N];
    int i;
    stin(S);
    memset(C, 0, sizeof C);
//    stout(S);
    check(S, C);
//    REP(i,N) { iout(C[i]); }
    REP(i,Q) {
        int l = iin(), r = iin();
        iout(C[l - 1] - C[r - 1]);
    }
    return 0;
}
//  [javascript]
const main = (input) => {
  const inputs = input.trim().split("\n");
  const N = Number(inputs[0].split(" ")[0]);
  const Q = Number(inputs[0].split(" ")[1]);
  const S = inputs[1];

  const map = [];
  var cnt = 0;
  for(var i=0;i<S.length;i++){
    if(S[i]=='C' && S[i-1]=='A'){
      cnt++;
    }
    map[i+1]=cnt;
  }


  for(var i=2;i<inputs.length;i++){
    var l = Number(inputs[i].split(" ")[0]);
    var r = Number(inputs[i].split(" ")[1]);
    console.log(map[r]-map[l]);
  }

}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
//  [javascript]
"use strict";
function Main(input) {
    let lines = input.split("\n");
    const nums = lines.shift().split(/\s/).map((v) => v - 0);
    const N = nums[0], Q = nums[1];
    let S = lines.shift().split(/\s/)[0];
    let T = new Array(N+1).fill(0);
    for (let m = 0; m < S.length; m++) {
        T[m + 1] = T[m] + ((m + 1 < N) && (S.substr(m, 2) == 'AC') ? 1 : 0);
    }
    for (let n = 0; n < Q; n++) {
        let lr = lines.shift().split(/\s/).map((v) => v - 0 - 1);
        const l = lr[0], r = lr[1];
        console.log(T[r] - T[l]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
// https://atcoder.jp/contests/abc122/tasks/abc122_c

package main

import "fmt"
import "sort"

func main() {
	var N, Q int
	fmt.Scanf("%d %d", &N, &Q)

	var s string
	fmt.Scanf("%s", &s)

	indices := []int{}
	for i := 0; i < len(s)-1; i++ {
		if s[i] == 'A' && s[i+1] == 'C' {
			indices = append(indices, i)
		}
	}

	indicesRev := append([]int{}, indices...)
	sort.Sort(sort.Reverse(sort.IntSlice(indicesRev)))

	for i := 0; i < Q; i++ {
		var r, l int
		fmt.Scanf("%d %d", &l, &r)
		l--
		r--

		lp := sort.Search(len(indices), func(i int) bool { return l <= indices[i] })
		rp := sort.Search(len(indicesRev), func(i int) bool { return indicesRev[i]+1 <= r })
		if rp >= len(indicesRev) && lp >= len(indices) {
			fmt.Println(0)
			continue
		}

		rp = len(indicesRev) - (rp + 1)
		fmt.Println(rp - lp + 1)
	}
}
//  [go]
package main

import (
    "fmt"
)

func bsearch(needle int, haystack []int) int {
    i, j := 0, len(haystack)
    for i < j {
        h := i + (j - i) / 2
        if haystack[h] < needle {
            i = h + 1
        } else {
            j = h
        }
    }
    return i
}

func main() {
    
    // fmt.Println(bsearch(0, []int{0, 2, 5}))

    scanInt()
    Q := scanInt()
    S := scanString()
    ac_positions := []int{}
    for i := 0; i < len(S) - 1; i++ {
        if S[i] == 'A' && S[i + 1] == 'C' {
            ac_positions = append(ac_positions, i)
        }
    }
    // fmt.Println(ac_positions)
    ac_positions = append(ac_positions, 100000)
    for i := 0; i < Q; i++ {
        l, r := scanInt(), scanInt()
        l_pos := bsearch(l - 1, ac_positions)
        r_pos := bsearch(r - 2, ac_positions)
        // fmt.Println(l_pos, r_pos)
        if ac_positions[r_pos] == r - 2 {
            fmt.Println(r_pos - l_pos + 1)
        } else {
            fmt.Println(r_pos - l_pos)
        }
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}
//  [go]
// "C"で区切る累積和
package main
import "fmt"
func main(){
	var N, Q int
	var S string
	fmt.Scan(&N, &Q, &S)
	T := make([]string, N)
	for i, c := range []rune(S){
		T[i] = string(c)
	}
	Ruiseki := make([]int, N+1)
	for i:=1; i<N; i++{
		Ruiseki[i+1] = Ruiseki[i]
		if T[i-1] == "A" && T[i] == "C"{
			Ruiseki[i+1]++
		}
	}
	for i:=0; i<Q; i++{
		var L, R int
		fmt.Scan(&L, &R)
		fmt.Println(Ruiseki[R]-Ruiseki[L])
	}
}
//  [ruby]
N,Q = gets.split.map &:to_i
S = gets.chomp
ss = []
(1...S.size).each{ |i|
  if S[i-1..i] == "AC"
    ss << [i,i+1]
  end
}
#p sb,se
Q.times {
  l,r = gets.split.map &:to_i
  il = (0...ss.size).bsearch{ |i| l <= ss[i][0] } || ss.size
  ir = (0...ss.size).bsearch{ |i| r < ss[i][1] } || ss.size
  #p [l,r,il,ir,S[l-1..r-1]]
  p [ir - il, 0].max
}
//  [ruby]
n, q=gets.split
s=[t=0]+gets.chars.map{|e|t+=(n+=e)[-2,2]=='AC' ? 1 : 0}
q.to_i.times{|e|l, r=gets.split; puts s[r.to_i]-s[l.to_i]}
//  [ruby]
n, q = gets.chomp.split.map(&:to_i)
s = gets.chomp
l = []
r = []
q.times do |i|
  l[i], r[i] = gets.chomp.split.map(&:to_i)
end

memo = []
(n-1).times do |i|
  if s[i..i+1] == 'AC'
    memo.push(i)
  end
end

q.times do |i|
  le = l[i] - 1
  ri = r[i] - 2
  le_ind = memo.bsearch_index { |x| x >= le } || memo.size
  ri_ind = memo.bsearch_index { |x| x > ri } || memo.size
  p ri_ind - le_ind
end
//  [rust]
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::*;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
  input! {
  n: usize,
  q: usize,
  s:Chars,
  mut q: [(Usize1, Usize1); q],
  }

  //i文字までのAの数
  let mut t = vec![0; s.len()];

  let mut cnt = 0;
  for i in 0..s.len() {
    if s[i] == 'A' {
      if i <= s.len() - 2 {
        if s[i + 1] == 'C' {
          cnt += 1;
        }
      }
    }
    if i < s.len() -1 {
      t[i+1] = cnt;
    }
  }

  debug!(q);
  debug!(t);

  for q1 in q {
    println!("{}", t[q1.1] - t[q1.0]);
  }
}
//  [rust]
fn main(){
  let nq: Vec<usize> = read_vec();
  let n = nq[0];
  let q = nq[1];

  let s: String = read();
  let sv: Vec<char> = s.chars().collect();
  let mut ac: Vec<usize> = vec![0;n+1];

  for i in 1 .. n {
   if sv[i-1] == 'A' && sv[i] == 'C' {
     ac[i+1] = ac[i] + 1;
   } else {
     ac[i+1] = ac[i];
   }
  }
  
  for _ in 0 .. q {
    let lr: Vec<usize> = read_vec();
    let l = lr[0];
    let r = lr[1];

    println!("{}", ac[r] - ac[l]);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}
//  [rust]
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let q = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();

    let mut table = vec![0; n];
    table[0] = 0;
    for i in 1..s.len() {
        if s[i - 1] == 'A' && s[i] == 'C' {
            table[i] = table[i - 1] + 1
        } else {
            table[i] = table[i - 1]
        }
    }

    for _ in 0..q {
        let l = read::<usize>() - 1;
        let r = read::<usize>() - 1;
        println!("{}", table[r] - table[l])
    }
}
//  [swift]
import Foundation

extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
}

let input = readLine()!.split(by: " ").map{Int($0)!}
let N = input[0]
let Q = input[1]
let S = readLine()!.characters.map{$0}

var sum = [0]
for i in 1...N {
    sum.append(sum[i-1])
    if (i != N) && (S[i-1] == "A") && (S[i] == "C") {
        sum[i] += 1
    }
}

for _ in 0..<Q {
    let input = readLine()!.split(by: " ").map{Int($0)!}
    print(sum[input[1]-1] - sum[input[0]-1])
}
//  [swift]
import Foundation

extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
}

let input = readLine()!.split(by: " ").map{Int($0)!}
let N = input[0]
let Q = input[1]
let S = readLine()!.characters.map{$0} + ["_"]

var sum = [0]
for i in 1...N {
    sum.append(sum[i-1])
    if (S[i-1] == "A") && (S[i] == "C") {
        sum[i] += 1
    }
}

for _ in 0..<Q {
    let input = readLine()!.split(by: " ").map{Int($0)!}
    print(sum[input[1]-1] - sum[input[0]-1])
}
//  [typescript]
import { print } from 'util';

namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    const [N, Q]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    const S = await sc.getLine();
    const l: number[] = [];
    const r: number[] = [];
    for (let i = 0; i < Q; i += 1) {
      const [t1, t2] = (await sc.getLine()).split(' ').map((x) => +x);
      l.push(t1);
      r.push(t2);
    }
    const t: number[] = Array(N + 1).fill(0);
    for (let i = 0; i < N; i += 1) {
      let c = 0;
      if (S.substr(i, 2) === 'AC') {
        c = 1;
      }
      t[i + 1] = t[i] + c;
    }

    for (let i = 0; i < Q; i += 1) {
      console.log(t[r[i] - 1] - t[l[i] - 1]);
    }

    sc.close();
  }

  solve();
}
//  [typescript]
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();

const lines = input.split('\n');
const [_, text, ...indexes] = lines;
const textArray = text.split('');

const [acMap] = textArray.reduce(([acMap, prevCount, prevChar], c, i) => {
    const count = prevChar === 'A' && c === 'C' ? prevCount + 1 : prevCount;
    acMap[i] = count;
    return [acMap, count, c];
}, [[], 0, '']);

indexes.forEach((line) => {
    const [i, j] = line.split(' ').map(Number);
    console.log(acMap[j - 1] - acMap[i - 1]);
});
//  [typescript]
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();

const lines = input.split('\n');
const [_, text, ...indexes] = lines;

const acMap = new Array(text.length);
let count = 0, prev = '', char = '', i = 0;
for (; i < text.length; i++) {
    if (text[i-1] === 'A' && text[i] === 'C') {
        count++;
    }
    acMap[i] = count;
}

indexes.forEach((line) => {
    const [i, j] = line.split(' ').map(Number);
    console.log(acMap[j - 1] - acMap[i - 1]);
});
//  [python]
import math
n=int(input())
for i in range(1,n+1):
    nn=int(math.sqrt(i))
    min=int((nn+1)/math.sqrt(3))
    min1=int((nn+1)/math.sqrt(2))
    count=0
    for x in range(1,min+1):
        for y in range(x,min1+1):
            for z in range(y,nn+1):
                #print(x*x+y*y+z*z+x*y+y*z+z*x)
                if (x*x+y*y+z*z+x*y+y*z+z*x)==i:
                    if x==y and y==z and z==x:
                        count=count+1
                    elif x!=y and y!=z and z!=x:
                        count=count+6
                    else:
                        count=count+3
    print(count)
//  [python]
from collections import Counter
N = int(input())
MAX_INT = 10**4+1
cumsum = [0] * (MAX_INT)

# 3~6
for i in range(3, 150):
  seen = []
  for n in range(1, i+1):
    for m in range(n, i+1):
      k = i - n - m
      if k <= 0: continue
      tmp = [n,m,k]
      tmp.sort()
      if tmp in seen: continue
      seen.append(tmp)

      p = i*i - (n*m + m*k + k*n)
      if p >= MAX_INT: break
      l = len(list(set(tmp)))
  
      if l==3:
        add = 6
      elif l==2:
        add = 3
      else:
        add = 1

      cumsum[p] += add
      
for i in range(1, N+1):
  print(cumsum[i])
//  [python]
n = int(input())
f = [0]*100000005
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            x = i**2 + j**2 + k**2 + i*j + j*k+ k*i
            f[x] += 1

for i in range(1, n + 1):
    print(f[i])
//  [java]
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        var sb = new StringBuilder();
        for (int l = 1; l <= n; l++) {
            int cnt = 0;
            for (int i = 1; i * i <= n; i++) {
                for (int j = 1; j * j <= n; j++) {
                    for (int k = 1; k * k <= n; k++) {
                        if (i * i + j * j + k * k + i * j + j * k + k * i > l) {
                            break;
                        }
                        if (i * i + j * j + k * k + i * j + j * k + k * i == l) {
                            cnt++;
                        }
                    }
                }
            }
            sb.append(cnt);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }
}
//  [java]
import java.util.Scanner;

public class Main {
    public static int valid(long x, long y,long z,long n){
        return (z*z+x*x+y*y+y*z+x*y+x*z==n?1:0);
    }
    public static int solve(int n){
        int ans=0;
        for (long x = 1; x*x+x*2 <= n ; x++) {
            for (long y = 1; y*y+x*y+x*x+x+y <= n ; y++) {
                for (long z = 1; z*z+x*x+y*y+y*z+x*y+x*z<= n ; z++) {
                    ans+= valid(x,y,z,n);
                }
            }
        }
        return ans;
    }
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int n;
        n = scan.nextInt();
        for (int i = 1; i <= n ; i++) {
            System.out.println(solve(i));
        }
    }
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int x=1;x<=n;++x){
        int cnt=0;
        for(int i=1;i<=x;++i){
            if(((i*i)+1+1+i+1+i)>x) break;
            for(int j=1;j<=x;++j){
                if(((i*i)+(j*j)+1+(i*j)+j+i)>x) break;
                for(int k=1;k<=x;++k){
                    if(((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i))>x) break;
                    if(((i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(k*i))==x) ++cnt;
                }
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> count(N,0);
  
  for (int x=1;x<sqrt(N);x++){
    for (int y=x;y<sqrt(N);y++){
      for (int z=y;z<sqrt(N);z++){
        for (int i=0;i<N;i++)
          if ( (pow(x+y+z,2)-(x*y+y*z+z*x))==i+1 )
            if (x==y && y==z)
              count.at(i)+=1;
        	else if (x==y || y==z)
              count.at(i)+=3;
        	else
              count.at(i)+=6;
      }
    }
  }
  for (int i=0;i<N;i++)
    cout << count.at(i) << endl;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin>>n;
  
  vector<vector<int>> vec(100, vector<int>(100));
  for(int i=0;i<100;i++){
    for(int j=0;j<100;j++){
      vec.at(i).at(j)=(i+1)*(j+1);
    }
  }
  
  
  for(int p=1;p<n+1;p++){
    int ans=0;
    for(int i=0;i<100;i++){
      if(6*(i+1)*(i+1)==p){
        ans-=2;
      }
    }
    for(int i=0;i<100;i++){
      for(int j=0;j<100;j++){
        if(3*(i+1)*(i+1)+2*(i+1)*(j+1)+(j+1)*(j+1)==p){
          ans+=3;
        }
      }
    }
  for(int i=0;i<100;i++){
    if(6*(i+1)*(i+1)<p){
      continue;
    }
    if((i+1)*(i+1)+2*(i+1)+3>p){
      break;
    }
    for(int j=0;j<i;j++){
      for(int k=0;k<j;k++){
        if(vec.at(i).at(j)+vec.at(i).at(k)+vec.at(j).at(k)+vec.at(i).at(i)+vec.at(j).at(j)+vec.at(k).at(k)==p){
         ans+=6;
              
        }
      }
    }
  }
    cout<<ans<<endl;
  }
}
//  [c]
//C - XYZ Triplets
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
typedef long long ll;
//#define N 998244353
#define pi 3.1415926535897932384626433832

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  int n,x,y,z;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
            int ans=0;
            for(z = 1; z < sqrt(i); z++) {
              for(y = 1; y < sqrt(i); y++) {
                for(x = 1; x < sqrt(i); x++) {
                  if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                    ans++;
                    break;
                  }
                  if(x*x+y*y+z*z+x*y+y*z+z*x>i){
                    break;
                  }
                }
              }
            }
            printf("%d\n", ans);
  }
  return 0;
}
//  [c]
#include<stdio.h>
int main () {
    int N;
    scanf("%d",&N);
    int b[N];
    int i,x,y,z,m;
    for(i=0;i<N;i++){
        b[i] = 0;
        for(x=1;x<=80;x++){
            for(y=x;y<=90;y++){
                for(z=y;z<=100;z++){
                    m = x*x + y*y + z*z + x*y + y*z + z*x;
                    if(m == (i+1)){
                        if(x == y && y == z){
                            b[i] += 1;
                        }else if(x != y && y != z && z != x){
                            b[i] += 6;
                        }else{
                            b[i] += 3;
                        }
                    }
                }
            }
        }
        printf("%d\n",b[i]);
    }
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int a,b,c,n,i,j,k,count,x=1,y=1,z=1,temp;

scanf("%d",&n);
  
  	for(i=1;i<=n;i++){
      count=0;
      x=1;
      y=1;
      z=1;
      //(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)<=2*i
  for(x=1;x*x<=2*i;x++){
    for(y=1;y<=x;y++){
      for(z=1;z<=y;z++){
        //printf("(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)=%d, 2*i=%d\n",(x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x),2*i);
        if((x+y)*(x+y)+(y+z)*(y+z)+(z+x)*(z+x)==2*i){
          if(z==y){
          if(y==x){
          count++;
          }
          else{
          count+=3;
          }
          }
            
            else if(y==x){
            count+=3;
            }
          
          else{
          
          count+=6;
          }
        }
    }
        
  }
  
  }
      
    printf("%d\n",count);
      
    }
  
return 0;
}
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

"use strict";
//x^2+y^2+z^2+xy+yz+zx=n
function calc(n) {
    let count=0
    for(let x=1; x*x<=n; x++) {
        for(let y=1; y*y<=n; y++) {
            const a = 1
            const b = x+y
            const c = x**2+y**2+x*y-n
            const judge = (b**2-4*a*c)
            if(judge>=0) {
                let z0 = (-b-judge**0.5)/(2*a)
                let z1 = (-b+judge**0.5)/(2*a)
                if(z0 >= 1 && z0===parseInt(z0,10))count++
                if(z1 >= 1 && z1===parseInt(z1,10))count++
                /*
                if(z1 >= 1 && z1===parseInt(z1,10)) count++
                */
                //console.log(`x=${x}, y=${y}, z0=${z0},z1=${z1}`)
                
            }            
        }
    }
    return count
}

function main(arg) {
    const n = parseInt(arg)
    for(let i=1; i<=n; i++) {
        //console.log(`-------i=${i}-------`)
        let ans = calc(i)
        console.log(ans)
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const lines = input.split('\n')
    const N = lines[0] - 0

    const f = (x, y, z) => {
        return  x * x + y * y + z * z + x * y + y * z + x * z
    }

    const map = Array(N + 1).fill(0)
    for (let i = 1; i <= N; i++) {
        for (let j = 1; j <= N; j++) {
            for (let k = 1; k <= N; k++) {
                const n = f(i, j, k)
                if (n <= N)  {
                    map[n] ++
                } else {
                    break
                }
            }
        }
    }

    map.shift()
    map.forEach(n => {
        console.log(n)
    })

})(input)
//  [go]
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	for i := 1; i <= N; i++ {
		cnt := 0
		for x := 1; x*x <= i; x++ {
			for y := 1; x*x+y*y <= i; y++ {
				for z := 1; x*x+y*y+z*z+x*y+y*z+x*z <= i; z++ {
					if x*x+y*y+z*z+x*y+y*z+x*z == i {
						cnt++
					}
				}
			}
		}
		fmt.Println(cnt)
	}

}

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) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 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
		}
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	for n := 1; n <= N; n++ {
		res := 0

		for i := 1; i*i <= n; i++ {
			for j := 1; i*i+j*j+i*j <= n; j++ {
				for k := 1; i*i+j*j+k*k+i*j+i*k+k*j <= n; k++ {
					if i*i+j*j+k*k+i*j+i*k+k*j == n {
						res++
					}
				}
			}
		}
		fmt.Printf("%d\n", res)
	}
}
//  [ruby]
n = gets.chomp.to_i
a = (1..150).map{|i|i}
combs = a.repeated_permutation(3).to_a

def hoge(x,y,z)
  x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x
end

hash = {}
combs.each do |c|
  result = hoge(*c)
  hash[result] ? hash[result] += 1 : hash[result] = 1
end

n.times do |i|
  puts hash[i+1] ? hash[i+1] : 0
end
//  [ruby]
def f(xyz)
    xyz[0]*xyz[0] + xyz[1]*xyz[1] + xyz[2]*xyz[2] + xyz[0]*xyz[1] + xyz[1]*xyz[2] + xyz[2]*xyz[0]
end
 
def countCombination(xyz)
    c = xyz.uniq.size
    if c == 1 then
        return 1
    elsif c == 2 then
        return 3
    else
        return 6
    end
end
 
n = gets.chomp.to_i
MAX = 1000000
ans = Array.new(MAX, 0)
 
[*1..300].repeated_combination(3) do |xyz|
    ans[f(xyz)] += countCombination(xyz)
end
 
(1..n).each do |i|
    puts ans[i]
end
//  [ruby]
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
n = gets_i

def calc(x, y, z)
  x**2 + y**2 + z**2 + x * y + y * z + z * x
end

x, y, z = 1,1,1

ans = []

x.upto(100) do |xi|
  y.upto(100) do |yi|
    z.upto(100) do |zi|
      ans.push(calc(xi, yi, zi))
    end
  end
end
ans.sort

ha = ans.sort.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

1.upto(n) do |i|
  if ha[i]
    puts ha[i]
  else
    puts 0
  end
end
//  [rust]
use proconio::marker::*;
use proconio::*;

fn main() {
    input! {
        n: usize,
    };

    let mut ans = 0;

    for i in 1..=n {
        println!("{}", f(i));
    }
}

fn f(n: usize) -> usize {
    let mut res = 0;

    for x in 1..=100 {
        for y in x..=100 {
            for z in y..=100 {
                if x * x + y * y + z * z + x * y + x * z + y * z == n {
                    if x == y && y == z {
                        res += 1;
                    } else if x == y || y == z || x == z {
                        res += 3;
                    } else {
                        res += 6;
                    }
                }
            }
        }
    }

    res
}
//  [rust]
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();

    for n in 1..=N {
        let mut count = 0_usize;
        let mut x = 1;
        while x * x <= n {
            let x2 = x * x;

            let mut y = 1;
            while x2 + y * y <= n {
                let y2 = y * y;

                let mut z = 1;
                while x2 + y2 + z * z <= n {
                    let z2 = z * z;

                    if x2 + y2 + z2 + x * y + y * z + z * x == n {
                        count += 1;
                    }

                    z += 1;
                }

                y += 1;
            }

            x += 1;
        }

        println!("{}", count);
    }
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
    }

    let range = ((n as f64).sqrt().ceil()) as usize;
    let mut cnt = 0;

    for i in 1..n+1 {
        for x in 1..range+1 {
            for y in x..range+1{
                for z in y..range+1 {
                    if x*x+y*y+z*z+x*y+y*z+z*x==i {
                        if x==y && y==z && z==x{
                            cnt += 1;
                        } else if x!=y && y!=z && z!=x {
                            cnt += 6;
                        } else {
                            cnt += 3;
                        }
                    }
                }
            }
        }
        println!("{}", cnt);
        cnt = 0;
    }
}
//  [swift]
import Foundation

func originSqrt(_ n: Int) -> Int {
    return Int(sqrt(Double(max(0,n))))
}

let N = Int(readLine()!)!

for n in 1...N {
    var cnt = 0
    for x in 1...originSqrt(n)+1 {
        let xx = x * x
        for y in 1...originSqrt(n-xx)+1 {
            let yy = y * y
            let xy = x * y
            for z in 1...originSqrt(n-xx-yy)+1 {
                let zz = z * z
                let yz = y * z
                let zx = z * x
                let f_n = xx + yy + zz + xy + yz + zx
                if n == f_n {
                    cnt += 1
                }
            }
        }
    }
    print(cnt)
}
//  [swift]
let n = Int(readLine()!)!
func f(_ n: Int) -> Int {
    var c = 0
    for x in 1...n {
        guard x*x <= n else { break }
        for y in 1...n {
            guard x*x+y*(x+y) <= n else { break }
            for z in 1...n {
                guard x*x+y*(x+y)+z*(x+y+z) <= n else { break }
                if x*x+y*(x+y)+z*(x+y+z) == n {
                    c += 1
                }
            }
        }
    }
    return c
}
for i in 1...n {
    print(f(i))
}
//  [swift]
//
//  main.swift
//  TestSpace for AtCoder
//
//  Created by Koichi Okai on 2020/06/25.
//  Copyright © 2020 Koichi Okai. All rights reserved.
//

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let N = Int(readLine()!)!
    
    for n in (1...N) {
        var c:Int = 0
        for x in (1...n) {
            let X = x*x
            if(X >= n) { break }
            for y in (1...(n-X)) {
                let Y = y*y
                let xy = x*y
                if(X+Y+xy >= n) { break }
                for z in (1...(n-X-Y-xy)) {
                    let Z = z*z
                    let yz = y*z
                    let zx = z*x
                    if(X+Y+Z+xy+yz+zx > n) { break }
                    else if(X+Y+Z+xy+yz+zx == n) {
                        c += 1
                    }
                }
            }
        }
        print(c)
    }
    
}

main()
//  [python]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    s = input()
    a = int(s[0:2])
    b = int(s[2:4])
    dump(a,b)

    if (1 <= a <= 12 and 1 <= b <= 12):
        print("AMBIGUOUS")
    elif (1 <= a <= 12):
        print("MMYY")
    elif (1 <= b <= 12):
        print("YYMM")
    else:
        print("NA")

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}
//  [python]
s = input()

if 0<int(s[:2])<13:
  if 0<int(s[2:])<13:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 0<int(s[2:])<13:
    print("YYMM")
  else:
    print("NA")
//  [java]
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.ResolverStyle;
import java.util.Scanner;

public class Main {
	final static String YYMM = "YYMM";
	final static String MMYY = "MMYY";
	final static String AMBIGUOUS = "AMBIGUOUS";
	final static String NA = "NA";
	final static String patern = "uuMMdd";
	final static String day = "01";
	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		boolean yymm = true, mmyy = true;
		try {
			DateTimeFormatter.ofPattern(patern)
			.withResolverStyle(ResolverStyle.STRICT)
			.parse(S + day, LocalDate::from);
		} catch (Exception e) {
			yymm = false;
		}
		try {
			String y = S.substring(2, 4);
			String m = S.substring(0, 2);
			DateTimeFormatter.ofPattern(patern)
			.withResolverStyle(ResolverStyle.STRICT)
			.parse(y + m + day, LocalDate::from);
		} catch (Exception e) {
			mmyy = false;
		}
		if(yymm && mmyy) System.out.println(AMBIGUOUS);
		else if(yymm) System.out.println(YYMM);
		else if(mmyy) System.out.println(MMYY);
		else System.out.println(NA);
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

int mxN = 50000000;
vector<int> cnt(mxN + 1);

int main() {
    string ss;
    cin >> ss;
    int f = stoi(ss.substr(0, 2)), s = stoi(ss.substr(2));
    if (ss.substr(2) == "00" && ss.substr(0, 2) == "00") {
        cout << "NA";
        return 0;
    }
    if (ss.substr(0, 2) == "00") {
        if (s <= 12) {
            cout << "YYMM";
            return 0;
        }
        else {
            cout << "NA";
            return 0;
        }
    }
    if(ss.substr(2) == "00") {
        if (f <= 12) {
            cout << "MMYY";
            return 0;
        }
        else {
            cout << "NA";
            return 0;
        }
    }
    
    if (f > 12 && s > 12) {
        cout << "NA";
        return 0;
    }
    if (f <= 12 && s <= 12) {
        cout << "AMBIGUOUS";
        return 0;
    }
    if (f <= 12) {
        cout << "MMYY";
        return 0;
    }
    if (s <= 12) {
        cout << "YYMM";
        return 0;
    }
    cout << "NA";


    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)

template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
//******************************************************************************

string s;

signed main()
{
	//IOS();
	cin>>s;
	int a = (s[0]-'0')*10+s[1]-'0';
	int t = (s[2]-'0')*10+s[3]-'0';
	int f1 = (0<a&&a<=12),f2 = (0<t&&t<=12);
	if(f1&&f2){
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}else if(f2){
		cout<<"YYMM"<<endl;
		return 0;
	}else if(f1){
		cout<<"MMYY"<<endl;
		return 0;
	}else{
		cout<<"NA"<<endl;
		return 0;
	}
}
//  [c]
#include<stdio.h>

main()

{
    long long int S, Y, M;

    scanf("%lld",&S);
    Y = S / 100;
    M = S % 100 ;

    if( ((Y>=1)&&(Y<=12)) &&
            ((M>=1)&&(M<=12)) )
    {
        printf("AMBIGUOUS\n");
    }

    else if(Y >= 1 && Y <= 12)
    {
        printf("MMYY\n");
    }

    else if(M >= 1 && M<=12)
    {
        printf("YYMM\n");
    }

    else
    {
        printf("NA\n");
    }
    
    return 0;
}
//  [c]
#include <stdio.h>


int main(void) {
	int input_num = 0;
	int YYMM_flag1 = 0;
	int YYMM_flag2 = 0;
	int MMYY_flag1 = 0;
	int MMYY_flag2 = 0;

	
	if(scanf("%d", &input_num)==1);

	if (0 <= (input_num % 100) && (input_num % 100) <= 99) {
		MMYY_flag1 = 1;
		if (1 <= (input_num / 100) && (input_num / 100) <= 12) {
			MMYY_flag2 = 1;
		}
	}
	if (1 <= (input_num % 100) && (input_num % 100) <= 12) {
		YYMM_flag1 = 1;
		if (0 <= (input_num / 100) && (input_num / 100) <= 99) {
			YYMM_flag2 = 1;
		}
	}
	if (MMYY_flag1 == 1 && MMYY_flag2 == 1 && YYMM_flag1 == 1 && YYMM_flag2 == 1) {
		printf("AMBIGUOUS\n");
	}
	else if (MMYY_flag1 == 1 && MMYY_flag2 == 1 && (YYMM_flag1 == 0 || YYMM_flag2 == 0)) {
		printf("MMYY\n");
	}
	else if ((MMYY_flag1 == 0 || MMYY_flag2 == 0) && YYMM_flag1 == 1 && YYMM_flag2 == 1) {
		printf("YYMM\n");
	}
	else {
		printf("NA\n");
	}

}
//  [c]
#include<stdio.h>

int main() {
   int S;
   scanf("%d", &S);
   int a = S / 100;
   int b = S % 100;
   if(b <= 12 && b > 0) {
      if(a <= 12 && a > 0) {
         printf("AMBIGUOUS");
      } else {
         printf("YYMM");
      }
   } else {
      if(a <= 12 && a > 0) {
         printf("MMYY");
      } else {
         printf("NA");
      }
   }
}
//  [javascript]
const main = (input) => {
  var S = input.trim();
  var isAYY=false,isBYY=false,isAMM=false,isBMM=false;

  var A = Number(S[0]+S[1]);
  var B = Number(S[2]+S[3]);

  if(A>=1 && A<=12){
    isAMM = true;
  }
  if(B>=1 && B<=12){
    isBMM = true;
  }
  if(isAMM && isBMM){
    console.log('AMBIGUOUS');
  }else if(isAMM){
    console.log('MMYY');
  }else if(isBMM){
    console.log('YYMM');
  }else{
    console.log('NA');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
//  [javascript]
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var s = o.a();
  var former = Math.floor(s/100);
  var later = s % 100;
  if (former <= 12 && former >= 1) {
    if (later <= 12 && later >= 1) {
      console.log("AMBIGUOUS");
    } else {
      console.log("MMYY");
    }
  } else if (later <= 12 && later >= 1) {
    console.log("YYMM");
  } else {
    console.log("NA");
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  var a = +(s[0]+s[1]);
  var b = +(s[2]+s[3]);
  var n = "NA";
  if((a > 12 || a === 0) && (b > 12 || b === 0))return n;
  if(a <= 12 && b <= 12 & a > 0 && b > 0)return "AMBIGUOUS";
  if(a <= 12 && a > 0)return "MMYY";
  return "YYMM"
}
//  [go]
package main

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

const BUFSIZE = 10000000

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	var s string
	var f1, f2 bool = true, true
	fmt.Scanf("%s", &s)

	prefix, _ := strconv.Atoi(s[:2])
	sufix, _ := strconv.Atoi(s[2:])

	if prefix > 12 || prefix == 0 {
		f1 = false
	}
	if sufix > 12 || sufix == 0 {
		f2 = false
	}

	if f1 && f2 {
		fmt.Println("AMBIGUOUS")
	} else if f1 {
		fmt.Println("MMYY")
	} else if f2 {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}

}

func NextLineInt() []int {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int, l)

	for i := range str {
		// ret[i], ok = strconv.Atoi(str[i])
		v, ok := strconv.Atoi(str[i])

		if ok == nil {
			ret[i] = v
		}
	}

	return ret
}

func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

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

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

func Distance(a, b int) int {
	return Abs(a - b)
}
//  [ruby]
s = gets.chomp
if s[0..1].to_i <= 12 && s[2..3].to_i <= 12 && s[0..1].to_i >= 1 && s[2..3].to_i >= 1
    puts "AMBIGUOUS"
elsif s[0..1].to_i <= 12 && s[2..3].to_i > 12 && s[0..1].to_i >= 1
    puts "MMYY"
elsif s[0..1].to_i <= 12 && s[2..3] == "00" && s[0..1].to_i >= 1
    puts "MMYY"
elsif s[0..1].to_i > 12 && s[2..3].to_i <= 12 && s[2..3].to_i >= 1
    puts "YYMM"
elsif  s[0..1] == "00" && s[2..3].to_i <= 12 && s[2..3].to_i >= 1
    puts "YYMM"
elsif  s[0..1].to_i > 12 && s[2..3].to_i > 12
    puts "NA"
elsif s[0..1] == "00" || s[2..3] == "00"
    puts "NA"
end
//  [ruby]
S = gets.chomp

a = S[0, 2].to_i
b = S[2, 2].to_i
if a == 0
  if b > 12 || b == 0
    puts "NA"
  else
    puts "YYMM"
  end
elsif a <= 12
  if b > 12 || b == 0
    puts "MMYY"
  else
    puts "AMBIGUOUS"
  end
else
  if b > 12 || b == 0
    puts "NA"
  else
    puts "YYMM"
  end
end
//  [ruby]
a,b,c,d=gets.split("").map &:to_s
a=(a+b).to_i
b=(c+d).to_i
ans1=1 if a>=1 && a<=12
ans2=1 if b>=1 && b<=12
if ans1==1 && ans2 ==1
  puts "AMBIGUOUS"
elsif ans1==1
  puts :MMYY
elsif ans2==1
  puts :YYMM
else
  puts :NA
end