#include <bits/stdc++.h>
using namespace std;
const int N = 2020, oo = 1000000000;
int i, j, k, n, m, rt, mi, Size;
int ls[N], rs[N], fa[N], sz[N], z[N];
char s[10];
void get_rt(int x, int F) {
  sz[x] = 1;
  int ma = 0;
  if (ls[x] && ls[x] != F && !z[ls[x]]) {
    get_rt(ls[x], x);
    sz[x] += sz[ls[x]];
    if (sz[ls[x]] > ma) ma = sz[ls[x]];
  }
  if (rs[x] && rs[x] != F && !z[rs[x]]) {
    get_rt(rs[x], x);
    sz[x] += sz[rs[x]];
    if (sz[rs[x]] > ma) ma = sz[rs[x]];
  }
  if (fa[x] && fa[x] != F && !z[fa[x]]) {
    get_rt(fa[x], x);
    sz[x] += sz[fa[x]];
    if (sz[fa[x]] > ma) ma = sz[fa[x]];
  }
  if (Size - sz[x] > ma) ma = Size - sz[x];
  if (ma < mi || (ma == mi && x > rt)) mi = ma, rt = x;
}
int get_sz(int x, int F) {
  sz[x] = 1;
  if (ls[x] && ls[x] != F && !z[ls[x]]) sz[x] += get_sz(ls[x], x);
  if (rs[x] && rs[x] != F && !z[rs[x]]) sz[x] += get_sz(rs[x], x);
  if (fa[x] && fa[x] != F && !z[fa[x]]) sz[x] += get_sz(fa[x], x);
  return sz[x];
}
int get_leaf(int x) {
  if (x <= n) return x;
  return get_leaf(ls[x]);
}
void Df(int x) {
  z[x] = 1;
  if (x <= n) {
    m++;
    if (ls[fa[x]] == x)
      ls[fa[x]] = m;
    else
      rs[fa[x]] = m;
    fa[m] = fa[x];
    fa[x] = m;
    fa[i] = m;
    ls[m] = x;
    rs[m] = i;
    return;
  }
  int a1 = get_leaf(ls[x]), a2 = get_leaf(rs[x]);
  printf("%d %d %d\n", a1, a2, i);
  fflush(stdout);
  scanf("%s", s);
  char ch = s[0];
  if (ch == 'X') {
    if (z[fa[x]] || fa[x] == 0) {
      m++;
      if (fa[x]) {
        if (ls[fa[x]] == x)
          ls[fa[x]] = m;
        else
          rs[fa[x]] = m;
        fa[m] = fa[x];
      }
      fa[x] = m;
      fa[i] = m;
      ls[m] = x;
      rs[m] = i;
      return;
    }
    Size = get_sz(fa[x], 0);
    mi = oo;
    get_rt(fa[x], 0);
    Df(rt);
  }
  if (ch == 'Y') {
    if (z[rs[x]]) {
      m++;
      fa[rs[x]] = m;
      fa[i] = m;
      ls[m] = rs[x];
      rs[m] = i;
      rs[x] = m;
      fa[m] = x;
      return;
    }
    Size = get_sz(rs[x], 0);
    mi = oo;
    get_rt(rs[x], 0);
    Df(rt);
  }
  if (ch == 'Z') {
    if (z[ls[x]]) {
      m++;
      fa[ls[x]] = m;
      fa[i] = m;
      ls[m] = ls[x];
      rs[m] = i;
      ls[x] = m;
      fa[m] = x;
      return;
    }
    Size = get_sz(ls[x], 0);
    mi = oo;
    get_rt(ls[x], 0);
    Df(rt);
  }
}
int main() {
  scanf("%d", &n);
  m = n;
  m++;
  ls[m] = 1;
  rs[m] = 2;
  fa[1] = fa[2] = m;
  for (i = 3; i <= n; i++) {
    memset(z, 0, sizeof z);
    Size = 2 * i - 3;
    mi = oo;
    get_rt(1, 0);
    Df(rt);
  }
  puts("-1");
  for (i = 1; i <= m; i++) {
    if (fa[i])
      printf("%d ", fa[i]);
    else
      printf("%d ", -1);
  }
}
