#![allow(unused_imports)] #![allow(non_snake_case, unused)] use std::cmp::*; use std::collections::*; use std::ops::*; // https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254 より macro_rules! eprint { ($($t:tt)*) => {{ use ::std::io::Write; let _ = write!(::std::io::stderr(), $($t)*); }}; } macro_rules! eprintln { () => { eprintln!(""); }; ($($t:tt)*) => {{ use ::std::io::Write; let _ = writeln!(::std::io::stderr(), $($t)*); }}; } macro_rules! dbg { ($v:expr) => {{ let val = $v; eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val); val }} } macro_rules! mat { ($($e:expr),*) => { Vec::from(vec![$($e),*]) }; ($($e:expr,)*) => { Vec::from(vec![$($e),*]) }; ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) }; ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) }; } macro_rules! ok { ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => { $a$([$i])*.$f($($t),*) }; ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { { let t = $e; ok!($a$([$i])*.$f($($es),*)$(@$t)*@t) } }; } pub fn readln() -> String { let mut line = String::new(); ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e)); line } macro_rules! read { ($($t:tt),*; $n:expr) => {{ let stdin = ::std::io::stdin(); let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| { let line = line.unwrap(); let mut it = line.split_whitespace(); _read!(it; $($t),*) }).collect::>(); ret }}; ($($t:tt),*) => {{ let line = readln(); let mut it = line.split_whitespace(); _read!(it; $($t),*) }}; } macro_rules! _read { ($it:ident; [char]) => { _read!($it; String).chars().collect::>() }; ($it:ident; [u8]) => { Vec::from(_read!($it; String).into_bytes()) }; ($it:ident; usize1) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::().unwrap_or_else(|e| panic!("{}", e)) - 1 }; ($it:ident; [usize1]) => { $it.map(|s| s.parse::().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::>() }; ($it:ident; [$t:ty]) => { $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::>() }; ($it:ident; $t:ty) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e)) }; ($it:ident; $($t:tt),+) => { ($(_read!($it; $t)),*) }; } pub fn main() { let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join(); } const MOD: usize = 998244353; // const MOD: usize = 1_000_000_007; const INF: i64 = std::i64::MAX/100; // const INF: usize = std::usize::MAX; // const INF: i128 = std::i128::MAX/100; fn solve() { let n = read!(usize); let total = n*n - n; let mut count = vec![vec![0;2*n+1];2*n+1]; let mut list = vec![vec![vec![];2*n+1];2*n+1]; for i in 2..=total { let (p,q) = query(1,i); let a = (n as i64 + p) as usize; let b = (n as i64 + q) as usize; count[a][b] += 1; list[a][b].push(i-1); } let mut ans = vec![(0,0);total]; for a in 1..=n-1 { for b in 0..=n-1 { let mut c = vec![vec![0;2*n+1];2*n+1]; for x in 1..=n-1 { for y in 0..=n-1 { if (a,b)==(x,y) { continue; } let p = n + a - x; let q = n + b - y; c[min(p,q)][max(p,q)] += 1; } } let mut flag = true; for x in 0..=2*n { for y in 0..=2*n { if count[x][y]!=c[x][y] { // if (a,b)==(2,1) { // println!("{} {} {}",x,y,c[x][y]); // } flag = false; } } } if flag { // println!("{} {}",a,b); ans[0] = (a,b); } } } let (s,t) = (ans[0].0 as i64, ans[0].1 as i64); for x in 0..=2*n { for y in 0..=2*n { if count[x][y]==1 { let idx = list[x][y][0]; let a = x as i64 - n as i64; let b = y as i64 - n as i64; if 1<=(s-a)&&(s-a)<=(n-1) as i64&&0<=(t-b)&&(t-b)<=(n-1) as i64 { ans[idx] = ((s-a) as usize,(t-b) as usize); } else { ans[idx] = ((s-b) as usize,(t-a) as usize); } } } } for i in 0..total{ for x in 0..=2*n { for y in 0..=2*n { if count[x][y]==2 { let (idx1,idx2) = (list[x][y][0],list[x][y][1]); let a = x as i64 - n as i64; let b = y as i64 - n as i64; let (a1,b1) = (s-a,t-b); let (a2,b2) = (s-b,t-a); let mut target = 0; let mut td = (0,0); for d in 1..total { if ans[d]==(0,0) || d==idx1 || d==idx2 { continue; } let (e,f) = (ans[d].0 as i64, ans[d].1 as i64); let mut c1 = a1 - e; let mut d1 = b1 - f; let mut c2 = a2 - e; let mut d2 = b2 - f; if (min(c1,d1),max(c1,d1)) == (min(c2,d2),max(c2,d2)) { target = d; td = (min(c1,d1),max(c1,d1)); break; } } if target==0 { continue; } let (p,q) = query(idx1+1,target+1); if (p,q)==td { ans[idx1] = (a1 as usize, b1 as usize); ans[idx2] = (a2 as usize, b2 as usize); } else { ans[idx2] = (a1 as usize, b1 as usize); ans[idx1] = (a2 as usize, b2 as usize); } count[x][y] = 0; } } } } print!("! "); for i in 0..total { print!("{} ",ans[i].0*n + ans[i].1); } println!(); } fn query(x: usize, y: usize) -> (i64,i64) { println!("? {} {}", x, y); let ans = read!(i64,i64); ans } fn run() { let stack_size = 104_857_600; // 100 MB let thd = std::thread::Builder::new().stack_size(stack_size); solve(); }