process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

function main(input) {
  let ptr = 0
  let t = readInt(input, ptr++)
  // const alpha = "abcdefghijklmnopqrstuvwxyz"
  while(t--) {
    const s = input[ptr++]
    let ans = ''
    let l = s.length
    let map = new Array(26)
    for(let i = 0; i < 26; i++) {
      map[i] = [-1,-1]
    }
    let done = {}

    let curr = s.charCodeAt(0) - 97
    ans = s[0]
    done[curr] = true
    let f = true
    for(let i = 1; i < l && f; i++) {
      let char = s.charCodeAt(i) - 97
      if(map[curr][0] === char || map[curr][1] === char) {
        curr = char
      }
      else if(map[curr][0] === -1 && !done[char]) {
        map[curr][0] = char
        map[char][1] = curr
        curr = char
        done[char] = true
        ans = s[i] + ans
      }
      else if(map[curr][1] === -1 && !done[char]) {
        map[curr][1] = char
        map[char][0] = curr
        curr = char
        done[char] = true
        ans = ans + s[i]
      }
      else f = false
    }
    if(f) {
      wr('YES')
      for(let i = 0; i < 26; i++) {
        if(!done[i]) ans += String.fromCharCode(i + 97)
      }
      wr(ans)
    }
    else wr('NO')
    // wr(map)
  }
}

'use strict'

const problem = (s) => {
    if (s.length < 2) return 'YES\nabcdefghijklmnopqrstuvwxyz';
    if (s.length === 2) return 'YES\n' + s + 'abcdefghijklmnopqrstuvwxyz'.replace(s[0], '').replace(s[1], '')
    let a = [ s[0], s[1] ];
    let j = 1;
    for (let i = 2; i < s.length; i++) {
        const next = s[i];
        const l = a[j-1];
        const r = a[j+1];
        if (next === l) { j--; continue; }
        if (next === r) { j++; continue; }
        if (a.indexOf(next) !== -1) return 'NO';

        if (j === a.length - 1) { j++; a.push(next); continue; }
        if (j === 0) { a.unshift(next); continue; }
        return 'NO'
    }
    let others = 'abcdefghijklmnopqrstuvwxyz';
    for (let i = 0; i < a.length; i++) others = others.replace(a[i], '');
    return 'YES\n' + a.join('') + others;
}
let t = +readline();
while(t--) print(problem(readline()))

const alphabet = 'bacdefghijklmnopqrstuvwxyz'.split('')

const linkNode = (tree, keyA, keyB) => {
  const elA = tree[keyA]
  const elB = tree[keyB]
  const left = elA.left
  const right = elA.right
  if (left === keyB || right === keyB){
    return
  }
  const freeA = []
  if (!elA.left) {
    freeA.push('left')
  }
  if (!elA.right) {
    freeA.push('right')
  }
  if (freeA.length === 0) {
    throw new Error('overflow')
  }
  let usedProp = null

  for (const prop of freeA) {
    if (prop === 'left') {
      if (!elB.right) {
        usedProp = ['left', 'right']
      }
    } else {
      if (!elB.left) {
        usedProp = ['right', 'left']
      }
    }
  }

  if (!usedProp) {
    throw new Error('no link')
  }
  elA[usedProp[0]] = keyB
  elB[usedProp[1]] = keyA
}

const processData = (lines) => {
  const num = +lines[0]

  for (let j=0; j<num; j++){
    const pass = lines[j+1].split('')
    const tree = {}
    try {
      for (let i = 0; i < pass.length; i++) {
        const letter = pass[i]
        tree[letter] = tree[letter] || {}
        if (i > 0) {
          const prevLetter = pass[i - 1]
          tree[prevLetter] = tree[prevLetter] || {}
          linkNode(tree, letter, prevLetter)
        }
        if (i < pass.length - 1) {
          const nextLetter = pass[i + 1]
          tree[nextLetter] = tree[nextLetter] || {}
          linkNode(tree, letter, nextLetter)
        }
      }
      let result = ''
      const firstLetter = Object.keys(tree)[0]
      let mark = firstLetter
      let usedMap = {}
      let isOk = true
      // go to left
      while (mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = mark + result
        usedMap[mark] = true
        if (tree[mark].left) {
          mark = tree[mark].left
        } else {
          mark = null
        }
      }

      if (tree[firstLetter].right) {
        mark = tree[firstLetter].right
      }

      // go to right
      while (isOk && mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = result + mark
        usedMap[mark] = true
        if (tree[mark].right) {
          mark = tree[mark].right
        } else {
          mark = null
        }
      }

      if (isOk) {
        console.log('YES')
        for (const a of alphabet) {
          if (!usedMap[a]) {
            result += a
          }
        }
        console.log(result)
      } else {
        console.log('NO')
      }
    } catch(e) {
      console.log('NO')
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

'use strict'

const problem = (s) => {
    if (s.length < 2) return 'YES\nabcdefghijklmnopqrstuvwxyz';
    if (s.length === 2) return s + 'abcdefghijklmnopqrstuvwxyz'.replace(s[0], '').replace(s[1], '')
    let a = [ s[0], s[1] ];
    let j = 1;
    for (let i = 2; i < s.length; i++) {
        const next = s[i];
        const l = a[j-1];
        const r = a[j+1];
        if (next === l) { j--; continue; }
        if (next === r) { j++; continue; }
        if (a.indexOf(next) !== -1) return 'NO';

        if (j === a.length - 1) { j++; a.push(next); continue; }
        if (j === 0) { a.unshift(next); continue; }
        return 'NO'
    }
    let others = 'abcdefghijklmnopqrstuvwxyz';
    for (let i = 0; i < a.length; i++) others = others.replace(a[i], '');
    return 'YES\n' + a.join('') + others;
}
let t = +readline();
while(t--) print(problem(readline()))

'use strict'

const problem = (s) => {
    if (s.length < 2) return 'YES\nabcdefghijklmnopqrstuvwxyz';
    if (s.length === 2) return s + 'abcdefghijklmnopqrstuvwxyz'.replace(s[0], '').replace(s[1], '')
    let a = [ s[0], s[1] ];
    let b = new Set(a);
    let j = 1;
    for (let i = 2; i < s.length; i++) {
        const next = s[i];
        const l = a[j-1];
        const r = a[j+1];
        if (next === l) { j--; continue; }
        if (next === r) { j++; continue; }
        if (b.has(next)) return 'NO';

        b.add(next);
        if (j === a.length - 1) { j++; a.push(next); continue; }
        if (j === 0) { a.unshift(next); continue; }
        return 'NO'
    }
    let others = 'abcdefghijklmnopqrstuvwxyz';
    for (let i of b) others = others.replace(i, '');
    return 'YES\n' + a.join('') + others;
}
let t = +readline();
while(t--) print(problem(readline()))

process.stdin.resume()
process.stdin.setEncoding('utf-8')

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main(arr)
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

function main(input) {
  let ptr = 0
  let t = readInt(input, ptr++)
  // const alpha = "abcdefghijklmnopqrstuvwxyz"
  while(t--) {
    const s = input[ptr++]
    let ans = ''
    let l = s.length
    let map = new Array(26)
    for(let i = 0; i < 26; i++) {
      map[i] = [-1,-1]
    }
    let done = {}

    let curr = s.charCodeAt(0) - 97
    ans = s[0]
    done[curr] = true
    let f = true
    for(let i = 1; i < l && f; i++) {
      let char = s.charCodeAt(i) - 97
      if(map[curr][0] === char || map[curr][1] === char) {
        curr = char
      }
      else if(map[curr][0] === -1 && !done[char]) {
        map[curr][0] = char
        map[char][1] = curr
        curr = char
        done[char] = true
        ans = s[i] + ans
      }
      else if(map[curr][1] === -1 && !done[char]) {
        map[curr][1] = char
        map[char][0] = curr
        curr = char
        done[char] = true
        ans = ans + s[i]
      }
      else f = false
    }
    if(f) {
      wr('YES')
      for(let i = 0; i < 26; i++) {
        if(!done[i]) ans += String.fromCharCode(i + 97)
      }
      wr(ans)
    }
    else wr('N0')
    // wr(map)
  }
}

const alphabet = 'bacdefghijklmnopqrstuvwxyz'.split('')

const linkNode = (tree, keyA, keyB) => {
  const elA = tree[keyA]
  const elB = tree[keyB]
  const left = elA.left
  const right = elA.right
  if (left === keyB || right === keyB){
    return
  }
  const freeA = []
  const freeB = []
  if (!elA.left) {
    freeA.push('left')
  }
  if (!elA.right) {
    freeA.push('right')
  }
  if (freeA.length === 0) {
    throw new Error('overflow')
  }
  let usedProp = null
  for (let prop in freeA) {
    if (prop === 'left') {
      if (!elB.right) {
        usedProp = ['left', 'right']
      }
    } else {
      if (!elB.left) {
        usedProp = ['right', 'left']
      }
    }
  }

  if (!usedProp) {
    throw new Error('no link')
  }
  elA[usedProp[0]] = keyB
  elB[usedProp[1]] = keyA
}

const processData = (lines) => {
  const num = +lines[0]

  for (let j=0; j<num; j++){
    const pass = lines[j+1].split('')
    const tree = {}
    try {
      for (let i = 0; i < pass.length; i++) {
        const letter = pass[i]
        tree[letter] = tree[letter] || {}
        if (i > 0) {
          const prevLetter = pass[i - 1]
          tree[prevLetter] = tree[prevLetter] || {}
          linkNode(tree, letter, prevLetter)
        }
        if (i < pass.length - 1) {
          const nextLetter = pass[i + 1]
          tree[nextLetter] = tree[nextLetter] || {}
          linkNode(tree, letter, nextLetter)
        }
      }
      let result = ''
      const firstLetter = Object.keys(tree)[0]
      let mark = firstLetter
      let usedMap = {}
      let isOk = true
      // go to left
      while (mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = mark + result
        usedMap[mark] = true
        if (tree[mark].left) {
          mark = tree[mark].left
        } else {
          mark = null
        }
      }

      if (tree[firstLetter].right) {
        mark = tree[firstLetter].right
      }

      // go to right
      while (isOk && mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = result + mark
        usedMap[mark] = true
        if (tree[mark].right) {
          mark = tree[mark].right
        } else {
          mark = null
        }
      }

      if (isOk) {
        console.log('YES')
        for (const a of alphabet) {
          if (!usedMap[a]) {
            result += a
          }
        }
        console.log(result)
      } else {
        console.log('NO')
      }
    } catch(e) {
      console.log('NO')
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

const alphabet = 'bacdefghijklmnopqrstuvwxyz'.split('')

const linkNode = (tree, keyA, keyB) => {
  const elA = tree[keyA]
  const elB = tree[keyB]
  const left = elA.left
  const right = elA.right
  if (left === keyB || right === keyB){
    return
  }
  const freeA = []
  const freeB = []
  if (!elA.left) {
    freeA.push('left')
  }
  if (!elA.right) {
    freeA.push('right')
  }
  if (freeA.length === 0) {
    console.log(tree)
    console.log(keyA, keyB)
    throw new Error('overflow')
  }
  let usedProp = null
  for (let prop in freeA) {
    if (prop === 'left') {
      if (!elB.right) {
        usedProp = ['left', 'right']
      }
    } else {
      if (!elB.left) {
        usedProp = ['right', 'left']
      }
    }
  }

  if (!usedProp) {
    throw new Error('no link')
  }
  elA[usedProp[0]] = keyB
  elB[usedProp[1]] = keyA
}

const processData = (lines) => {
  const num = +lines[0]

  for (let j=0; j<num; j++){
    const pass = lines[j+1].split('')
    const tree = {}
    try {
      for (let i = 0; i < pass.length; i++) {
        const letter = pass[i]
        tree[letter] = tree[letter] || {}
        if (i > 0) {
          const prevLetter = pass[i - 1]
          tree[prevLetter] = tree[prevLetter] || {}
          linkNode(tree, letter, prevLetter)
        }
        if (i < pass.length - 1) {
          const nextLetter = pass[i + 1]
          tree[nextLetter] = tree[nextLetter] || {}
          linkNode(tree, letter, nextLetter)
        }
      }
      let result = ''
      const firstLetter = Object.keys(tree)[0]
      let mark = firstLetter
      let usedMap = {}
      let isOk = true
      // go to left
      while (mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = mark + result
        usedMap[mark] = true
        if (tree[mark].left) {
          mark = tree[mark].left
        } else {
          mark = null
        }
      }

      if (tree[firstLetter].right) {
        mark = tree[firstLetter].right
      }

      // go to right
      while (isOk && mark) {
        if (usedMap[mark]) {
          isOk = false
          break;
        }
        result = result + mark
        usedMap[mark] = true
        if (tree[mark].right) {
          mark = tree[mark].right
        } else {
          mark = null
        }
      }

      if (isOk) {
        console.log('YES')
        for (const a of alphabet) {
          if (!usedMap[a]) {
            result += a
          }
        }
        console.log(result)
      } else {
        console.log('NO')
      }
    } catch(e) {
      console.error(e)
      console.log('NO')
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


'use strict';

function solve(n, m, a) {
  const h = new Array(n).fill(-1),
        e = [],
        ne = [],
        w = [];
  let idx = 0;
  const add = (i, j, c) => {
    e[idx] = j, ne[idx] = h[i], w[idx] = c, h[i] = idx++;
  };
  for (let [x, y, z] of a) {
    const i = Number(x) - 1,
          j = Number(y) - 1;
    if (z === 'imposter') {
      add(i, j, 1);
      add(j, i, 1);
    } else {
      add(i, j, 0);
      add(j, i, 0);
    }
  }
  const vis = [];
  const nums = new Array(n);
  const check = i => {
    const query = [i];
    nums[i] = 0;
    for (let i of query) {
      vis[i] = 1;
      for (let k = h[i]; k !== -1; k = ne[k]) {
        const j = e[k];
        if (nums[j] !== undefined && nums[j] !== (nums[i] ^ w[k])) return -1;
        if (vis[j]) continue;
        vis[j] = 1;
        nums[j] = nums[i] ^ w[k];
        query.push(j);
      }
    }
    let res = 0;
    for (let i of query) res += nums[i];
    return Math.max(res, query.length - res);
  };
  let res = 0;
  for (let i = 0; i < n; i++) {
    if (vis[i]) continue;
    const ans = check(i);
    if (ans === -1) return -1;
    res += ans;
  }
  return res;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const [n, m] = (await read()).split(' ').map(Number);
      const a = [];
      let tmp = m;
      while (tmp--) {
        a.push((await read()).split(' '));
      }
      res[i] = solve(n, m, a);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const says = lines.slice(l, l + m).map(str => str.trim().split(' ').map((x, i) => i < 2 ? +x : x))
        l += m
        console.log(solve(n, m, says))
    }
// })()
})

function solve(n, m, says) {
    const vs = Array(n + 1).fill(-1)
    const adj = {}
    says.forEach(([a, b, s]) => {
        adj[a] = adj[a] || []
        adj[b] = adj[b] || []
        const w = s === 'crewmate' // same or not
        adj[a].push([b, w])
        adj[b].push([a, w])
    })

    let c0 = 0
    let c1 = 0
    const visited = {}
    for (let i = 1; i <= n; i++) {
        if (!visited[i]) {
            const r = dfs(adj, i, visited, vs)
            if (!r) return -1

            const [a, b] = r
            c0 += Math.max(a, b)
            c1 += Math.min(a, b)
        }
    }

    return c0 + (n - c0 - c1)
}
function dfs(adj, r, visited) {
    const stack = [[r, 0, -1, 1]]
    let c0 = 0
    let c1 = 0
    const cache = []
    while (stack.length) {
        const [u, i, p, color] = stack[stack.length - 1]
        visited[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
            cache[u] = color
            if (color === 0) c0++
            if (color === 1) c1++
        }
        if (i < nb.length) {
            stack[stack.length - 1][1]++
            const [v, w] = nb[i]
            if (!visited[v]) { // has circle
                stack.push([v, 0, u, w ? color : (1 ^ color)])
            } else {
                if (w && cache[u] !== cache[v]) return null
                if (!w && cache[u] !== (1 ^ cache[v])) return null
            }
        } else {
            // last visited
            stack.pop()
        }
    }
    return [c0, c1]
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const says = lines.slice(l, l + m).map(str => str.trim().split(' ').map((x, i) => i < 2 ? +x : x))
        l += m
        console.log(solve(n, m, says))
    }
// })()
})

function solve(n, m, says) {
    const vs = Array(n + 1).fill(-1)
    const adj = {}
    const not = says.some(([a, b, s]) => {
        if (vs[a] < 0 && vs[b] < 0) {
            vs[a] = 1
            vs[b] = s === 'crewmate' ? 1 : 0
        } else if (vs[b] < 0) {
            vs[b] = s === 'crewmate' ? vs[a] : (vs[a] ^ 1)
        } else if (vs[a] < 0) {
            vs[a] = s === 'crewmate' ? vs[b] : (vs[b] ^ 1)
        } else {
            if (s === 'crewmate' && vs[a] !== vs[b]) return true
            if (s === 'imposter' && vs[a] === vs[b]) return true
        }
        adj[a] = adj[a] || []
        adj[b] = adj[b] || []
        adj[a].push(b)
        adj[b].push(a)
    })
    if (not) return -1

    let c0 = 0
    let c1 = 0
    const visited = {}
    for (let i = 1; i <= n; i++) {
        if (!visited[i]) {
            const [a, b] = dfs(adj, i, visited, vs)
            c0 += Math.max(a, b)
            c1 += Math.min(a, b)
        }
    }

    return c0 + (n - c0 - c1)
}
function dfs(adj, r, visited, vs) {
    const stack = [[r, 0, -1]]
    let c0 = 0
    let c1 = 0
    while (stack.length) {
        const [u, i, p] = stack[stack.length - 1]
        visited[u] = 1

        const nb = adj[u] || []
        if (!i) {
            // first visited
            if (vs[u] === 0) c0++
            if (vs[u] === 1) c1++
        }
        if (i < nb.length) {
            stack[stack.length - 1][1]++
            const v = nb[i]
            // if (!visited[v]) { // has circle
            if (v !== p && !visited[v]) {
                stack.push([v, 0, u])
            }
        } else {
            // last visited
            stack.pop()
        }
    }
    return [c0, c1]
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const says = lines.slice(l, l + m).map(str => str.trim().split(' ').map((x, i) => i < 2 ? +x : x))
        l += m
        console.log(solve(n, m, says))
    }
// })()
})

function solve(n, m, says) {
    const vs = Array(n + 1).fill(-1)
    // const adj = {}
    const not = says.some(([a, b, s]) => {
        if (vs[a] < 0 && vs[b] < 0) {
            vs[a] = 1
            vs[b] = s === 'crewmate' ? 1 : 0
        } else if (vs[b] < 0) {
            vs[b] = s === 'crewmate' ? vs[a] : (vs[a] ^ 1)
        } else if (vs[a] < 0) {
            vs[a] = s === 'crewmate' ? vs[b] : (vs[b] ^ 1)
        } else {
            if (s === 'crewmate' && vs[a] !== vs[b]) return true
            if (s === 'imposter' && vs[a] === vs[b]) return true
        }
        // adj[a] = adj[a] || []
        // adj[b] = adj[b] || []
        // adj[a].push(b)
        // adj[b].push(a)
    })
    if (not) return -1

    let c0 = 0
    let c1 = 0
    for (let i = 1; i <= n; i++) {
        if (vs[i] === 0) c0++
        if (vs[i] === 1) c1++
    }
    return Math.max(c0, c1) + (n - c0 - c1)
}


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => {
    return string.trim();
  });

  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  const n = parseInt(readline());
  const roads = new Map();
  let neighbours = (new Array(n+1)).fill(new Array());
  let start = 0,
      curr = 0,
      next = 0,
      d1 = 0,
      d2 = 0;
  for (let i=0; i<n; i++) {
    const [a, b, c] = readline().split(" ").map(x => parseInt(x));
    roads.set(a+"-"+b, c);
    neighbours[a] = neighbours[a].concat(b);
    neighbours[b] = neighbours[b].concat(a);
    if (start == 0) {
      start = a;
      curr = a;
      next = b;
    }
  }

  do {
    if (roads.has(curr+"-"+next)) {
      d1 += roads.get(curr+"-"+next);
    } else {
      d2 += roads.get(next+"-"+curr);
    }
    if (neighbours[next][0] == curr) {
      curr = next;
      next = neighbours[next][1];
    } else {
      curr = next;
      next = neighbours[next][0];
    }
  } while(curr != start);

  console.log(Math.min(d1,d2));
}

'use strict'

let lll

const N = +readline()

const rs = []

while (lll = readline()) {
  const rr = lll.split(' ').map(v => parseInt(v))
  if (!rs[rr[0]]) rs[rr[0]] = {rr: []}
  rs[rr[0]][rr[1]] = rr[2]
  rs[rr[0]].rr.push(rr[1])
  if (!rs[rr[1]]) rs[rr[1]] = {rr: []}
  rs[rr[1]][rr[0]] = 0
  rs[rr[1]].rr.push(rr[0])
}

const next = (f, t) => {
  const ws = rs[t].rr
  const n = ws[0] == f ? ws[1] : ws[0]
  const p = rs[t][n]
  return [n, p]
}

let r1 = 1
let r2 = rs[1].rr[0]
let p1 = rs[1][r2]

while (r2 != 1) {
  const w = next(r1, r2)
  const rn = w[0]
  r1 = r2
  r2 = rn
  p1 += w[1]
}

r1 = 1
r2 = rs[1].rr[1]
let p2 = rs[1][r2]

while (r2 != 1) {
  const w = next(r1, r2)
  const rn = w[0]
  r1 = r2
  r2 = rn
  p2 += w[1]
}

print(Math.min(p1, p2))

const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

var matrix = [], indicator = 0, N;
/**
 * while(true){
 *  string  input = Console.ReadLine();
 * }
 */
/**
 *
 *
  6
1 5 4
5 3 8
2 4 15
1 6 16
2 3 23
4 6 42

 */
var findNextPath = function (matrix, N, path, index) {
    for (let i = 0; i < N; i++) {
        if (matrix[index][i] != 0 && !path.includes(i) ||
            matrix[i][index] != 0 && !path.includes(i))
            return i;
    }
    return -1;
}

rl.on('line', (input) => {

    if (indicator == 0) {
        N = parseInt(input);
        indicator++;
        matrix = new Array(N).fill(0).map(() => new Array(N).fill(0));
        //console.log(matrix);
    }
    else {
        let temp = input.split(' ').map(item => parseInt(item));
        let a = temp[0], b = temp[1], price = temp[2];
        //console.log("a=%d  b=%d  price=%d",a,b,price);
        matrix[a - 1][b - 1] = price;

    }

}).on('close', () => {
    /**
     *
     * path{0,4,2,1,3,5}
     */
    //console.log(matrix);
    let path = [0];
    let nIndex = findNextPath(matrix, N, path, 0);

    while (nIndex != -1) {
        path.push(nIndex);
        nIndex = findNextPath(matrix, N, path, nIndex);
    }
    let CW = matrix[path[N - 1]][0];
    let ACW = matrix[0][path[N - 1]];

    for (let i = 0, j = N - 1; i < N - 1; i++, j--) {
        CW += matrix[path[i]][path[i + 1]];
        ACW += matrix[path[j]][path[j - 1]];
    }
    console.log((ACW > CW) ? CW : ACW);
});


const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let ch = 0, digit = 0;
    if (word.length === 0){
        return true;
    }
    for (let i = 0; i < Math.ceil(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
        if (word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
    }
    if (ch === 0){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false, ck = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if (x.length === 0)ck = true;
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0 && ck === false){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const zeroCharCode = '0'.charCodeAt(0);

const numberMap = new Map([
  [ zeroCharCode, 0 ],
  [ '1'.charCodeAt(0), 1 ],
  [ '2'.charCodeAt(0), 2 ],
  [ '3'.charCodeAt(0), 3 ],
  [ '4'.charCodeAt(0), 4 ],
  [ '5'.charCodeAt(0), 5 ],
  [ '6'.charCodeAt(0), 6 ],
  [ '7'.charCodeAt(0), 7 ],
  [ '8'.charCodeAt(0), 8 ],
  [ '9'.charCodeAt(0), 9 ]
]);
const isNumber = (str, at) => numberMap.has(str.charCodeAt(at));
const isNumeric = (str) => {
  if(str.length < 1) {
    return false;
  }

  if(str.length === 1) {
    return isNumber(str, 0);
  }

  if (str.charCodeAt(0) === zeroCharCode) {
    return false;
  }

  for (let i = str.length - 1; i >= 0; i--) {
    if(!isNumber(str, i)) {
      return false;
    }
  }
  return true;
}

const processInput = input => {
  const wordList = input.split(/[;,]/);
  /*
    input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );
  */

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumeric(word)) {
      a.push(word);
      return;
    }

    b.push(word);
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

var inputWords = [];
var separ = [',', ';'];
var inputRaw = readline();
inputWords = inputRaw.split(new RegExp(separ.join('|'), 'g'));

var numbers = "\"";
var nonNumbers = "\"";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

if (numbers.length === 1)
{
    numbers = "-";
}
else
{
    numbers = numbers.substr(0, numbers.length - 1);
    numbers += '\"';
}

if (nonNumbers.length === 1)
{
    nonNumbers = "-";
}
else
{
    nonNumbers = nonNumbers.substr(0, nonNumbers.length - 1);
    nonNumbers += '\"';
}

print (numbers);
print (nonNumbers);

readline().split(/,|;/).reduce((ab, word) => {
    if (!word || word.match(/^[0]+[0-9]+$/) || !word.match(/^\d+$/)) {
        ab[1].push(word);
    } else {
        ab[0].push(word);
    }
    return ab;
}, [[],[]])
.map(result => result.length > 0 ? "\"" + result.join(',') + "\"" : "-")
.forEach(result => print(result));

var inp = readline().split(/[,;]/g), n = inp.length;

var a = "", b = "";

for(var i = 0; i < n; i++){
    var str = inp[i];

    if(str === "") {b += str + ",";continue;}
    if(!/^\d+$/.test(str) && str != "0") { b += str + ","; continue; }
    if(/^0+/.test(str) && str != "0") { b += str + ","; continue; }
    a += str + ",";
}

if(a.length !== 0)
    print("\"" + a.substring(0, a.length - 1) + "\"");
else print("-");
if(b.length !== 0)
    print("\"" + b.substring(0, b.length - 1) + "\"");
else print("-");

var words = readline().split(/,|;/);
var s1 = [], s2 = [];
for(var x of words) {
	var n = ~~Number(x);
	if(String(n) === x && n >= 0) s1.push(x);
	else s2.push(x);
}

if(s1.length == 0) print("-");
else print('"' + s1.join(",") + '"');

if(s2.length == 0) print("-");
else print('"' + s2.join(",") + '"');

var words = readline().split(/,|;/);
var s1 = [], s2 = [];
for(var x of words) {
	var n = ~~+(x);
	if(String(n) === x && n >= 0) s1.push(x);
	else s2.push(x);
}

if(s1.length == 0) print("-");
else print('"' + s1.join(",") + '"');

if(s2.length == 0) print("-");
else print('"' + s2.join(",") + '"');

var inputWords = [];
var separ = [',', ';'];
var inputRaw = readline();
inputWords = inputRaw.split(new RegExp(separ.join('|'), 'g'));

var numbers = "\"";
var nonNumbers = "\"";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

if (numbers.length === 1)
{
    numbers += "-\"";
}
else
{
    numbers = numbers.substr(0, numbers.length - 1);
    numbers += '\"';
}

if (nonNumbers.length === 1)
{
    nonNumbers += "-\"";
}
else
{
    nonNumbers = nonNumbers.substr(0, nonNumbers.length - 1);
    nonNumbers += '\"';
}

print (numbers + "\n");
print (nonNumbers);

var inputWords = [];
var separ = [',', ';'];
var inputRaw = readline();
inputWords = inputRaw.split(new RegExp(separ.join('|'), 'g'));

var numbers = "\"";
var nonNumbers = "\"";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

if (numbers.length === 1)
{
    numbers += "-\"";
}
else
{
    numbers = numbers.substr(0, numbers.length - 1);
    numbers += '\"';
}

if (nonNumbers.length === 1)
{
    nonNumbers += "-\"";
}
else
{
    nonNumbers = nonNumbers.substr(0, nonNumbers.length - 1);
    nonNumbers += '\"';
}

print (numbers);
print (nonNumbers);

var inputWords = readline().split(",;");

var numbers;
var nonNumbers;

for (i = 0; i < inputWords.length; i++)
{
    var num = parseInt(inputWords[i]);
    if (typeof num === 'number')
    {
        var remainder = (num % 1);
        if (remainder === 0)
        {
            numbers += num + ",";
        }
        else
        {
            nonNumbers += num + "'";
        }
    }
}

print (numbers);
print (nonNumbers);

print("flavius");

var inputWords = [];
var separ = [',', ';'];
var inputRaw = readline();
inputWords = inputRaw.split(new RegExp(separ.join('|'), 'g'));

var numbers = "";
var nonNumbers = "";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

if (numbers.length === 0)
    numbers += "-";

if (nonNumbers.length === 0)
    nonNumbers += "-";

print (numbers + "\n");
print (nonNumbers);

var inputWords = [];
var separ = [',', ';'];
var inputRaw = readline();
inputWords = inputRaw.split(new RegExp(separ.join('|'), 'g'));

var numbers = "";
var nonNumbers = "";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

if (numbers.length == 0)
    numbers += "-";

if (nonNumbers.length == 0)
    nonNumbers += "-";

print (numbers + "\n");
print (nonNumbers);

var inputWords = [];
var separ = [',', ';'];
inputWords = readline().split(new RegExp(separ.join('|'), 'g'));

var numbers = "";
var nonNumbers = "";

for (i = 0; i < inputWords.length; i++)
{
    var reg = new RegExp('^[0-9]+$');
    if (reg.test(inputWords[i]))
    {
        if (inputWords[i].length > 1 && inputWords[i].charAt(0) == '0')
        {
            nonNumbers += inputWords[i] + ",";
        }
        else
        {
            numbers += inputWords[i] + ",";
        }
    }
    else
    {
        nonNumbers += inputWords[i] + ",";
    }
}

print (numbers + "\n");
print (nonNumbers);

readline().split(/,|;/).reduce((ab, word) => {
    if (!word || word.match(/[0]+[0-9]+/) || !word.match(/^\d+$/)) {
        ab[1].push(word);
    } else {
        ab[0].push(word);
    }
    return ab;
}, [[],[]])
.map(result => result.length > 0 ? "\"" + result.join(',') + "\"" : "-")
.forEach(result => print(result));

var inp = readline().split(/[,;]/g), n = inp.length;

var a = "", b = "";

for(var i = 0; i < n; i++){
    var str = inp[i];

    if(str === "" || isNaN(+str)) {b += str + ",";continue;}
    if(/^0+/.test(str) && str != "0") {b += str + ",";continue;}
    if(!/^\d+$/.test(str)) { b += str + ","; continue; }
    str = +str;
    a += str + ",";
}

if(a.length === 0)
    print("\"" + a.substring(0, a.length - 1) + "\"");
else print("-");
if(b.length === 0)
    print("\"" + b.substring(0, b.length - 1) + "\"");
else print("-");

var inp = readline().split(/[,;]/g), n = inp.length;

var a = "", b = "";

for(var i = 0; i < n; i++){
    var str = inp[i];

    if(str.length == "" || isNaN(+str)) {b += str + ",";continue;}
    if(/^0+/.test(str) && str != "0") {b += str + ",";continue;}
    if(!/^\d+$/.test(str)) { b += str + ","; continue; }
    str = +str;
    a += str + ",";
}

print("\"" + a.substring(0, a.length - 1) + "\"");
print("\"" + b.substring(0, b.length - 1) + "\"");

var inp = readline().split(/[,;]/g), n = inp.length;

var a = "", b = "";

for(var i = 0; i < n; i++){
    var str = inp[i];

    if(str === "" || isNaN(+str)) {b += str + ",";continue;}
    if(/^0+/.test(str) && str != "0") {b += str + ",";continue;}
    if(!/^\d+$/.test(str)) { b += str + ","; continue; }
    str = +str;
    a += str + ",";
}

if(a.length !== 0)
    print("\"" + a.substring(0, a.length - 1) + "\"");
else print("-");
if(b.length !== 0)
    print("\"" + b.substring(0, b.length - 1) + "\"");
else print("-");

var inp = readline().split(/,;/g), n = inp.length;

var a = "", b = "";

for(var i = 0; i < n; i++){
    var str = inp[i];

    if(str.length == "" || isNaN(+str)) {b += str + ",";continue;}
    if(/^0+/.test(str) && str != "0") {b += str + ",";continue;}
    if(!/^\d+$/.test(str)) { b += str + ","; continue; }
    str = +str;
    a += str + ",";
}

print("\"" + a.substring(0, a.length - 1) + "\"");
print("\"" + b.substring(0, b.length - 1) + "\"");

const isNumber = (val) => {
  const num = parseInt(val);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );
  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
    if (word.length < 1) {
      emptyCount++;
    }
  });

  process.stdout.write(`"${a.length < 1 ? '-' : a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(`"${b.length < 1 || b.length === emptyCount ? '-' : b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join(''));
    process.exit(0);
  });
})();

const isNumber = (val) => {
  const num = parseInt(val, 10);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );
  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
    if (word.length < 1) {
      emptyCount++;
    }
  });

  process.stdout.write(`"${a.length < 1 ? '-' : a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(`"${b.length < 1 || b.length === emptyCount ? '-' : b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join(''));
    process.exit(0);
  });
})();

const isNumber = str => /^[1-9][0-9]+$/.test(str);

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const isNumber = str => /^[0-9]+$/.test(str);

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const isNumber = (val) => {
  const num = parseInt(val, 10);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const isNumber = (val) => {
  const num = parseInt(val);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );
  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
    if (word.length < 1) {
      emptyCount++;
    }
  });

  process.stdout.write(a.length < 1 ? '-' : a.join(','));
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 || b.length === emptyCount ? '-' : b.join(','));
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join(''));
    process.exit(0);
  });
})();

const zeroCharCode = '0'.charCodeAt(0);
const numberMap = new Map([
  [ zeroCharCode, 0 ],
  [ '1'.charCodeAt(0), 1 ],
  [ '2'.charCodeAt(0), 2 ],
  [ '3'.charCodeAt(0), 3 ],
  [ '4'.charCodeAt(0), 4 ],
  [ '5'.charCodeAt(0), 5 ],
  [ '6'.charCodeAt(0), 6 ],
  [ '7'.charCodeAt(0), 7 ],
  [ '8'.charCodeAt(0), 8 ],
  [ '9'.charCodeAt(0), 9 ]
]);
const isNumber = (str, at) => numberMap.has(str.charCodeAt(at));
const isNumeric = (str) => {
  if(str.length < 1) {
    return false;
  }

  if(str.length === 1) {
    return isNumber(str, 0);
  }

  if (str.charCodeAt(0) !== zeroCharCode) {
    return false;
  }

  for (const i = str.length - 1; i >= 0; i--) {
    if(!isNumber(str, i)) {
      return false;
    }
  }
  return true;
}

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumeric(word)) {
      a.push(word);
      return;
    }

    b.push(word);
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const isNumber = (val) => {
  const num = parseInt(val, 10);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
    if (word.length < 1) {
      emptyCount++;
    }
  });

  process.stdout.write(`"${a.length < 1 ? '-' : a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(`"${b.length < 1 || b.length === emptyCount ? '-' : b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const isNumber = (val) => {
  const num = parseInt(val, 10);
  return `${num}` === val;
};

const processInput = input => {
  const wordList = input
    .split(',')
    .reduce(
      (list, item) => [...list, ...item.split(';')],
      []
    );

  let a = [];
  let b = [];
  let emptyCount = 0;
  wordList.forEach(word => {
    if(isNumber(word)) {
      a.push(word);
      return;
    }

    b.push(word);
    if (word.length < 1) {
      emptyCount++;
    }
  });

  process.stdout.write(a.length < 1 ?  '-' : `"${a.join(',')}"`);
  process.stdout.write('\n');
  process.stdout.write(b.length < 1 || b.length === emptyCount ?  '-' : `"${b.join(',')}"`);
};

(() => {
  process.stdin.setEncoding('utf8');
  const chunkList = [];
  process.stdin.on('readable', () => {
    let chunk;
    while ((chunk = process.stdin.read()) !== null) {
      chunkList.push(chunk);
    }
  });
  process.stdin.on('end', () => {
    processInput(chunkList.join('').trim());
    process.exit(0);
  });
})();

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let sum = 0;
    for (let i = 0; i <= Math.floor(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9' || word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            sum = sum + 1;
        }
    }
    if (sum === Math.floor(word.length / 2)){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let ch = 0, digit = 0;
    if (word.length === 0){
        return true;
    }
    for (let i = 0; i < Math.ceil(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
        if (word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
    }
    if (ch === 0){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    for (let i = 0; i <= Math.floor(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9' || word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            return false;
        }
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let ch = 0, digit = 0;
    if (word.length === 0){
        return true;
    }
    for (let i = 0; i < Math.ceil(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
        if (word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
    }
    if (ch === 0){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false, ck = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if (x.length === 0)ck = true;
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0 && ck === false){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    console.log(res);
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let ch = 0, digit = 0;
    if (word.length === 0){
        return true;
    }
    for (let i = 0; i < Math.ceil(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
        if (word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
    }
    if (ch === 0){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    console.log(res);
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    for (let i = 0; i < Math.floor(word.length / 2); i++){
        if (word[i] >= 'a' && word[i] <= 'z' || word[word.length - i - 1] >= 'a' && word[word.length - i - 1] <= 'z'){
            return true;
        }
        return false;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let ch = 0, digit = 0;
    for (let i = 0; i < Math.ceil(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
        if (word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            digit = digit + 1;
        } else {
            ch = ch + 1;
        }
    }
    if (ch === 0){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    for (let i = 0; i <= Math.floor(word.length / 2); i++){
        if (word[i] >= 'a' && word[i] <= 'z' || word[word.length - i - 1] >= 'a' && word[word.length - i - 1] <= 'z'){
            return true;
        }
        return false;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    for (let i = 0; i < Math.floor(word.length / 2); i++){
        if (word[i] >= 'a' && word[i] <= 'z' || word[word.length - i - 1] >= 'a' && word[word.length - i - 1] <= 'z'){
            return true;
        }
        return false;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log(a);
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log(b);
    }
    rl.close();
})

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

function findWord(word){
    let sum = 0;
    for (let i = 0; i <= Math.floor(word.length / 2); i++){
        if (word[i] >= '0' && word[i] <= '9' || word[word.length - i - 1] >= '0' && word[word.length - i - 1] <= '9'){
            sum++;
        }
    }
    if (sum === Math.floor(word.length / 2)){
        return false;
    } else {
        return true;
    }
}

rl.on('line', (input) => {
    s = "", a = "", b = "", flag1 = false, flag2 = false;
    res = input.split(/[,;]/);
    res.map(x => {
        if ((x.charAt(0) === '0' && x.length > 1) || findWord(x) || x.length === 0){
            if (flag1 === false)b += x;
            else b += "," + x;
            flag1 = true;
        }
        else {
            if (flag2 === false)a += x;
            else a += "," + x;
            flag2 = true;
        }
    });
    if (a.length === 0){
        console.log("-");
    } else {
        console.log("\"" + a + "\"");
    }
    if (b.length === 0){
        console.log("-");
    } else {
        console.log("\"" + b + "\"");
    }
    rl.close();
})


//var input = readline();
var T = parseInt(readline());

for (var i = 0; i < T; i++) {
    var n = parseInt(readline());
    if (n == 1) print(-1);
    else {
        write(2);
        n--;
        while (n-- > 0) {
            write(3);
        }   print('\n');
    }
}

process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    if(n === 1) wr(-1)
    else {
      let a = new Array(n).fill(9)
      a[n-1] = 8
      wr(a.join(''))
    }
  }
}

const mainFunction = (lines) => {
    let n = +lines[0];
    for(let i = 1; i < n + 1; i++) {
        let qwe = +lines[i];
        if(qwe != 1){ qwe--;
            let ans = "2";
            while(qwe--) ans += '3';
            console.log(ans);
        }
        else console.log(-1);
    }
}

const {EOL} = require('os')
const fs = require("fs");
if(__filename.substr(9,4) != "azer"){
    let yourInput = ''
    process.stdin.on('data', i => yourInput += i)
    process.stdin.on('end', () => mainFunction(yourInput.split(EOL)))
} else {
    mainFunction(fs.readFileSync('input.txt', 'utf8').split(EOL))
}

let yourInputData = ''
process.stdin.on('data', i => yourInputData += i)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = yourInputData.split(EOL)
    mainFunction(lines)
})

const mainFunction = (lines) => {
    let n = +lines[0];
    for(let i = 1; i < n + 1; i++) {
        let qwe = +lines[i];
        if(qwe != 1){ qwe--;
            let ans = "2";
            while(qwe--) ans += '3';
            console.log(ans);
        }
        else console.log(-1);
    }
}

var t = readline().split('\n');

for(var i = 1; i <= t ; ++i){
    var n = readline().split('\n');
    if(n == 1){
        print("-1");
    }
    else{
        var string = [];
        for(var j = 1; j <= n - 2 ; ++j)
            string += '9';

        string += '29';
        print(string);
    }
}

const mainFunction = (lines) => {
    let n = +lines[0];
    for(let i = 1; i < n + 1; i++) {
        let qwe = +lines[i];
        if(qwe != 1){ qwe--;
            let ans = "2";
            while(qwe--) ans += '3';
            console.log(ans);
        }
        else console.log(-1);
    }
}

const {EOL} = require('os')
const fs = require("fs");
if(__filename.substr(9,4) != "azer"){
    let yourInputData = ''
    process.stdin.on('data', i => yourInputData += i)
    process.stdin.on('end', () => {
        const lines = yourInputData.split(EOL)
        mainFunction(lines)
    })
} else {
    mainFunction(fs.readFileSync('input.txt', 'utf8').split(EOL))
}

process.stdin.resume();
process.stdin.setEncoding('utf-8')
let inputString = '';
let currentLine = 0;
process.stdin.on('data', input => { inputString += input })
process.stdin.on('end', _ => { inputString = inputString.trim().split('\n').map(str => str.trim()); main() })
const readline = () => { return inputString[currentLine++] }

function main() {
    let tests = parseInt(readline());
    while(tests--){
        let num = parseInt(readline());
        if(num == 1) console.log("-1");
        else{
            let ans = "3".repeat(num - 1);
            console.log("2"+ans);
        }
    }
}

const processData = (lines) => {
  const num = +lines[0]
  for (let j =0; j<num; j++) {
    const n = +lines[j+1]
    if (n<=1) {
      console.log(-1)
    } else {
      console.log((new Array(n -1).fill('5')).concat([8]).join(''))
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

const store = {};

function main() {
	let t = readLine() >> 0;

	while (t--) {
		let n = readLine() >> 0;

		if (n <= 1) {
			console.log(-1);
			continue;
		}

		console.log(`2${'3'.repeat(n - 1)}`);
	}
}

//var input = readline();
var T = parseInt(readline());

for (var i = 0; i < T; i++) {
    var n = parseInt(readline());
    if (n == 1) print(-1);
    else {
        write(3);
        n--;
        while (n-- > 0) {
            write(1);
        }
    }
}

var t = readline().split('\n');

for(var i = 1; i <= t ; ++i){
    var n = readline().split('\n');
    if(n == 1){
        print("-1");
    }
    var string = [];
    for(var j = 1; j <= n - 2 ; ++j)
        string += '9';

    string += '29';
    print(string);
}

var t = readline().split(' ');

for(var i = 1; i <= t ; ++i){
    var n = readline().split(' ');
    print(n);
}

var t = readline().split(' ');

for(var i = 1; i <= t ; ++i){
    var n = readline().split(' ');
    if(n == 1){
        print("-1");
    }
    var string = "";
    for(var j = 1; j <= n - 2 ; ++j)
        string += "9";

    string = string + "2" + "9";
    print(string);
}

var t = readline().split('\n');

for(var i = 1; i <= t ; ++i){
    var n = readline().split('\n');
    if(n == 1){
        print("-1");
    }
    var string = "";
    for(var j = 1; j <= n - 2 ; ++j)
        string += '9';

    string += '29';
    print(string);
}

var t = readline().split(' ');

for(var i = 1; i <= t ; ++i){
    var n = readline().split(' ');
    if(n == 1){
        print("-1\n");
    }
    for(var j = 1; j <= n - 2 ; ++j){
        print("9");
    }
    print("29\n");
}

var t = readline().split(' ');

for(var i = 1; i <= t ; ++i){
    var n = readline().split(' ');
    if(n == 1){
        print("-1");
    }
    var string = [];
    for(var j = 1; j <= n - 2 ; ++j)
        string += '9';

    string += '29';
    print(string);
}


process.stdin.resume();
process.stdin.setEncoding("ascii");

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on("data", function (data) {
  input_stdin += data;
});

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    b = b.split(" ");
    let n = parseInt(b[0]);
    let arr = [];
    while (n--) {
      var c = readLine();
      arr.push(c.replace("\r", ""));
    }
    var res = solveMeFirst(arr);
    // let out = "";
    // if (res) {
    //   for (let i = 0; i < res.length; i++) {
    //     out += res[i] + " ";
    //   }
    console.log(res);
    // }
  }
}
function solveMeFirst(arr) {
  // console.log(arr);
  let col = false;
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
      if (arr[i][j] === "R" && col === false) {
        col = j;
      } else if (arr[i][j] === "R" && col !== false) {
        if (col > j) return "NO";
      }
    }
  }
  return "YES";
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', stdin => inputString += stdin);

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(s => s.trim());
    main();
});

function readline() {
    return inputString[currentLine++];
}

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

class Robot {
    constructor(row, col) {
        this.row = row;
        this.col = col;
    }

    willExplode(first) {
        return this.row < first.row || this.col < first.col;
    }
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let n = parseInt(readline(), 10);

        let first;
        let willExplode = false;

        for (let i = 0; i < n; i++) {
            let row = readline().split('');

            for (let j = 0; j < row.length; j++) {
                if (row[j] === 'R') {
                    if (!first) {
                        first = new Robot(i, j);
                    } else {
                        let curr = new Robot(i, j);
                        if (curr.willExplode(first)) {
                            willExplode = true;
                        }
                    }
                }
            }
        }

        output(willExplode ? 'NO' : 'YES');
    }
}

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const [n, m] = lines[l++].trim().split(' ').map(Number)
        const grid = lines.slice(l, l + n).map(str => str.trim())
        l += n
        output[i] = solve(n, m, grid) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, m, grid) {
    let r = n
    let c = m
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (grid[i][j] === 'R') {
                r = Math.min(r, i)
                c = Math.min(c, j)
            }
        }
    }
    return r < n && c < m && grid[r][c] === 'R'
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let [inputString, currentLine] = ['', 0];
process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
});
const input = () => inputString[currentLine++];

const main = () => {
  let tc = parseInt(input());
  while(tc--){
    const [n, m] = input().split(' ').map(Number);
    const f = [];
    for(let i = 0; i < n; i++){
      const s = input().split('');
      f.push(s);
    }
    let my = n-1;
    let mx = m-1;
    for(let y = 0; y < n; y++){
      for(let x = 0; x < m; x++){
        if(f[y][x] === 'R'){
          my = Math.min(my, y);
          mx = Math.min(mx, x);
        }
      }
    }
    if(f[my][mx] === 'R') console.log("YES");
    else console.log("NO");
  }
}

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m, s) {
  let robot = null;
  for (let i = 0; i < n; i++) {
    for (let j = 0; j < m; j++) {
      if (s[i][j] === 'R') {
        if (!robot) {
          robot = [i, j];
        } else {
          if (i < robot[0] || j < robot[1]) {
            return 'NO';
          }
        }
      }
    }
  }
  return 'YES';
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    const a = [];
    let tmp = n;
    while (tmp--) {
      a.push(await read());
    }
    res.push(solve(n, m, a));
  }
  console.log(res.join('\n'));
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

const calc = ()=>{
    /* read */
    let [n, m] = ra();
    let grid = [];
    for (let i = 0; i < n; i++) {
        grid.push(readline().split(''));
    }
    // console.log('DEBUG grid', grid);

    let x, y;
    for (let i = 0; i < n; i++) {
        if (x !== undefined) break;
        for (let j = 0; j < m; j++) {
            if (grid[i][j] === 'R') {
                x = i;
                y = j;
                break;
            }
        }
    }
    // console.log('DEBUG x', x);
    // console.log('DEBUG y', y);

    for (let i = x; i < n; i++) {
        for (let j = 0; j < y; j++) {
            if (grid[i][j] === 'R') {
                return 'NO';
            }
        }
    }

    return 'YES';
};

function main() {
    let T = +readline();
    let out = [];
    for (let t = 1; t <= T; t++){
        out.push(calc());
        // process.stdout.write(`${calc(n, a)}\n`);
    }
    process.stdout.write(out.join('\n')+'\n');
}

'use strict';
// HEADER:
const print = console.log;
let IS_MULTITEST, testN;
const pcalc = testN=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    pa(res);
  } else if (Number.isFinite(res) || typeof res=='string'){
    print(res);
  }
};

const main = ()=>{
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T);
  } else
   pcalc();
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`Test #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let [n, m] = ra();
  let A = [];
  for (let i=0; i<n; i++)
    A.push(readline());
  LT({n, m, A});
  // PROCESSING:
  let mini = Infinity;
  let minj = Infinity;
  for (let i=0; i<n; i++){
    for (let j=0; j<m; j++){
      if (A[i][j]=='R'){
        mini = Math.min(mini, i)
        minj = Math.min(minj, j)
      }
    }
  }
  L({mini, minj})
  if (mini==Infinity)
    return 'NO'
  return A[mini][minj]=='R' ? 'YES' : 'NO'
};

var t = +readline();

for(var i = 0; i< t; i ++) {
    var ab = readline();
    var a = +ab[0];
    var b = ab[1];
    var list = [];
    for(var j = 0; j<a;j++){
          var test = readline();
          list.push(test);
    }
    print(Task1(list));

}

function Task1(grid){

   var find = null;
  var check = null;
  for(var i = 0; i<grid.length; i++){

    for(var j = 0; j<grid[0].length; j++){
      if (grid[i][j] === 'R'){
        if (find === null){
          find = j;
          check = j;
        }else {
          check = Math.min(check,j);
        }
      }

    }
  }
  if (check < find) return 'NO';
  else return 'YES';

}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
while (t--) {
    var _a = readline().split(' ').map(function (v) { return +v; }), n = _a[0], m = _a[1];
    var first = -1;
    var min = 10000;
    var firstX = 0, minY = 0;
    var a = Array(n);
    for (var i = 0; i < n; i++) {
        a[i] = readline();
        var index = a[i].indexOf('R');
        if (first === -1 && index !== -1) {
            first = i;
            firstX = index;
        }
        if (index !== -1 && index < min) {
            min = index;
            minY = i;
        }
    }
    print(firstX === min && minY === first ? 'YES' : 'NO');
}

process.stdin.resume();
process.stdin.setEncoding("ascii");

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on("data", function (data) {
  input_stdin += data;
});

process.stdin.on("end", function () {
  input_stdin_array = input_stdin.split("\n");
  // console.log(input_stdin_array);
  main();
});

function readLine() {
  return input_stdin_array[input_currentline++];
}

function main() {
  var a = readLine();
  while (a--) {
    var b = readLine();
    b = b.split(" ");
    let n = parseInt(b[0]);
    let arr = [];
    while (n--) {
      var c = readLine();
      arr.push(c.replace("\r", ""));
    }
    var res = solveMeFirst(arr);
    // let out = "";
    // if (res) {
    //   for (let i = 0; i < res.length; i++) {
    //     out += res[i] + " ";
    //   }
    console.log(res);
    // }
  }
}
function solveMeFirst(arr) {
  // console.log(arr);
  let col = false;
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr[i].length; j++) {
      if (arr[i][j] === "R" && !col) {
        col = j;
      } else if (arr[i][j] === "R" && col) {
        if (col > j) return "NO";
      }
    }
  }
  return "YES";
}

// console.log(solveMeFirst(2, [2, 3, 2, 4, 1, 3, 4, 1]));
// console.log(timeConversion([100, 90, 90, 80], [70, 80, 105]));


var amountOfSets = readline();
var results = [];
for (var i = 0; i<amountOfSets; i++) {
    var amountInSet = readline();
    var numbers = readline().split(' ');
    var evenNumber = false;
    var oddNumber = false;
    for (var j = 0; j<amountInSet; j++) {
        if (numbers[j]%2 === 0) {
            evenNumber = true;
        } else {
            oddNumber = true;
        }
        if (evenNumber && oddNumber) {
            results[i] = 'YES';
            break;
        }
    }
    if (!results[i]) {
        if (evenNumber) {
            results[i] = 'NO';
        } else if (amountInSet%2 === 0) {
            results[i] = 'NO';
        } else {
            results[i] = 'YES';
        }
    }
}

for (var t = 0; t<amountOfSets; t++) {
    print(results[t]);
}

process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  let t = readInt()
  while(t--) {
    const n = readInt()
    const a = readInts()
    let sum = a.reduce((a, b) => a + b, 0)
    if(sum % 2 === 1) {
      wr('YES')
    }
    else {
      let e = false
      let o = false
      a.forEach(el => {
        if(el % 2 === 0) e = true
        else o = true
      })
      if(!o || !e) {
        wr('NO')
      }
      else wr('YES')
    }
  }
}

function main() {
    n = readInt()
    li = readInts()
    odd = li.filter(x => x%2!=0).length
    even = li.filter(x => x%2==0).length
    //print(n, li)
    if ((n%2==1 || even>0) && odd>0){
        print("YES")
    } else {
        print("NO")
    }
}

const TESTCASES = true
/* NodeJS Footer by @satyamcse and @shivam1420*/
var readline = require('readline');
process.stdin.setEncoding('utf-8');
var rl = readline.createInterface({input: process.stdin, output: process.stdout});
var inp = "";
rl.on('line' , v => inp += v+"\n");
rl.on('close', () => {
    inp = inp.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
    if (TESTCASES){
        const cnt = readInt()
        for (let i = 0; i<cnt; i++){
            main()
        }
    } else {main()}
});
function sort(a, inc = true) {
    if(inc) a.sort((a, b) => a - b)
    else a.sort((a, b) => b - a)
}
var ptr = 0
function print(...x) {console.log(...x)}
function readInt() {return +inp[ptr++]}
function readLine() {return inp[ptr++]}
function readInts() {return inp[ptr++].split(' ').map(a => +a)}

//DISABLE THIS LINE END ENABLE NEXT
//const rl =  require('readline').createInterface({input: require('fs').createReadStream('input.txt')});
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const write = (...args) => {
    process.stdout.write(args.join(' ') );
}
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)

let rli = 0;
function readline() {
    return lines[rli++];
}

function main() {
    //var y = +readline() + 1;
    var y = +readline()
    while(y > 0) {
		var z = readline();
		var arr = readline();
		var a = arr.split(' ');
		var a_even = (a.length % 2 === 0)?1:0;
		var odd = 0;
		var even = 0;
		var res = 'NO';
		for(var i = 0 ; i < a.length; i++) {
			if (odd === 1 && a_even == 0) {
				res = 'YES';
				break;
			}
			if (odd == 1 && even == 1) {
				res = 'YES';
				break;
			}
			if (a[i] % 2 == 0) {
				even = 1;
			} else {
				odd = 1;
			}
		}
		if (odd === 1 && a_even == 0) {
			res = 'YES';
		}
		if (odd == 1 && even == 1) {
			res = 'YES';
		}
		write(res +'\n');
		//write("\n");
		y--;
    }
    //const check = (x) => (x + '').length === new Set(x + '').size
	//while (!check(y)) y++
    //write(y);
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 !== 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  let ans = 'NO';
  let sum = 0;

  for (let i = 0; i < arr.length; i++) {
    sum += arr[i];

    for (let j = 0; j < arr.length; j++) {
      if ((arr[i] + arr[j]) % 2 !== 0) {
        ans = 'YES';
        break;
      }
    }
  }

  if (sum % 2 !== 0) {
    ans = 'YES';
  }

  console.log(ans);

  c++;
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 !== 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  let sum = 0;

  let isOdd = false;
  let isEven = false;
  for (let i = 0; i < arr.length; i++) {
    sum += arr[i];

    if (arr[i] % 2 === 0) {
      isEven = true;
    }
    else {
      isOdd = true;
    }
  }

  if (sum % 2 !== 0 || (isEven && isOdd)) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  // let ans = 'NO';
  // let sum = 0;

  // for (let i = 0; i < arr.length; i++) {
  //   sum += arr[i];

  //   for (let j = 0; j < arr.length; j++) {
  //     if ((arr[i] + arr[j]) % 2 !== 0) {
  //       ans = 'YES';
  //       break;
  //     }
  //   }
  // }

  // if (sum % 2 !== 0) {
  //   ans = 'YES';
  // }

  // console.log(ans);

  c++;
});

const calc = (d, x) => Math.ceil( d / (x + 1) + x)

const processData = (lines) => {
  const num = +lines[0]

  for (let j=0; j<num; j++){
    const numsLine = lines[j*2+2].split(' ').map(x => x%2)
    let isEvenNum = false
    let isOddNum = false
    for (const n of numsLine) {
      if (n === 0) {
        isEvenNum = true
      }
      if (n === 1) {
        isOddNum = true
      }
    }
    if (isEvenNum && isOddNum){
      console.log('YES')
    } else {
      if (isOddNum && numsLine.reduce((r, x) => r + x, 0)%2 === 1){
        console.log('YES')
      } else {
        console.log('NO')
      }
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
});

const input = [];
readline.on('line', x => input.push(x));

readline.on('close', () => {
    const n = parseInt(input[0]);
    for (let i = 1; i <= n * 2; i += 2) {
        const len = parseInt(input[i]);
        let even = 0;
        let odd = 0;
        const arr = Array.from(input[i + 1].split(' '), x => {
            x = parseInt(x);
            if (x % 2 === 0) even++;
            else odd++;
            return x;
        });

        if (odd % 2 === 1) {
            console.log("YES");
        } else {
            if (odd + 1 > 1 && even - 1 >= 0) {
                console.log("YES");
            } else {
                console.log("NO");
            }
        }
    }
});

function processData(input) {
    //Enter your code here
    var data = input.split('\n')
    var tcs = Number(data[0])
    var line = 1
    for(var i = 0;i<tcs;i++){
        var len = Number(data[line])
        line++
        var arr = data[line].split(' ').map(a=>parseInt(a))
        line++
        var res = findOdd(len,arr)
        console.log(res)
    }
    function findOdd(len,arr){
        var sum = 0
        var countEven =0
        var countOdd =0
        for(var i = 0;i<len;i++){
            sum += arr[i]
        }
        if(sum%2==1){
              return "YES"
        }
        else{
           for(var i =0;i<len;i++){
               if(arr[i]%2==0){
                   countEven++
               }
               else{
                   countOdd++
               }
           }
            if(countEven>=1 && countOdd>=1){
                return "YES"
            }
            else{
                return "NO"
            }

        }
    }
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

'use strict'

let t = parseInt(readline())
while (t --> 0) {
  const n = parseInt(readline())
  const arr = readline().split(' ').map(num => parseInt(num))
  let odd = 0
  for (let i in arr) {
      if(arr[i] % 2) odd++
  }

  if ((odd % 2) || ((n - odd) > 0 && odd)) print('YES')
  else print('NO')
}

'use strict'

const problem = (n, a) => {
    const x = a[0];
    for (let i = 1; i < a.length; i++) if (a[i] !== x) return 'YES';
    if (x === 0 || a.length % 2 === 0) return 'NO';
    return 'YES'
}
let t = +readline();
while(t--) print(problem(+readline(), readline().split(' ').map(i => +i%2)))

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var N = myconv(next(),1);
        var list = myconv(next(),4);
            var odd = 0;
            var even = 0;
            for(var j = 0; j < N; j++){
                if(list[j] % 2 == 0){
                    even++;
                }else{
                    odd++;
                }
            }
            if(odd % 2 == 1 || (odd != 0 && odd % 2 == 0 && even >= 1)){
                output[i] = "YES";
            }else{
                output[i] = "NO";
            }
    }
    myout(myconv(output,9));
}

function readNum() {
  return Number(readline());
}
function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = readNum();
  for (var i = 0; i < testCasesNum; i++) {
    var len = readNum();
    var arr = readNumArray();
    var isEvenLen = len % 2 === 0;
    var checked = checkArr(arr);

    if (isEvenLen) {
      if (checked.hasEven && checked.hasOdd) {
        print("YES");
      } else {
        print("NO");
      }
    } else {
      if (checked.hasOdd) {
        print("YES");
      } else {
        print("NO");
      }
    }
  }

}

const checkArr = arr => {
  var hasOdd = false;
  var hasEven = false;
  for (var i = 0; i < arr.length; i++) {
    if (arr[i] % 2 === 0) {
      hasEven = true;
    } else {
      hasOdd = true;
    }
    if (hasEven && hasOdd) {
      break;
    }
  }
  return {
    hasEven,
    hasOdd
  };
};
main();

function main() {
    var t = parseInt(readline());
    while(t-- > 0) {
        var n = parseInt(readline());
        var s = readline().split(" ");

        var sum = 0;
        var even = false; odd = false;
        for(var i = 0; i < n; i++) {
            sum += parseInt(s[i]);
            if (s[i] % 2 === 0) even = true;
            else odd = true;
        }

        if (sum % 2 === 1 || (even && odd))
            print("YES")
        else
            print("NO")
    }
}

main();

function runProgram(input){
    input= input.split("\n");
    var t = Number(input[0]);
    for(var i=0;i<t;i++){

        var n = Number(input[2*i+1]);
        var arr = input[2*i+2].split(" ");
        var sum = 0;
        for(var k = 0;k<n;k++){
            sum = sum + Number(arr[k]);
        }
        if(sum%2==0){
            cnt=0
            for(var x=0;x<n;x++){
                if(Number(arr[x])%2==1){
                    cnt=cnt+1;
                }
            }
            if(cnt==n && n%2==0){
                console.log("NO");
            }
            else if(cnt==0){
                console.log("NO")
            }
            else{
                console.log("YES")
            }
        }
        else{
            console.log("YES")
        }
    }
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
    read += input;
});
process.stdin.on("end", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
});

process.on("SIGINT", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
    process.exit(0);
});

//O(N)
//O(1)
function runProgram(input){
    input= input.split("\n");
    var t = Number(input[0]);
    for(var i=0;i<t;i++){

        var n = Number(input[2*i+1]);
        var arr = input[2*i+2].split(" ");
        var sum = 0;
        for(var k = 0;k<n;k++){
            sum = sum + Number(arr[k]);
        }
        if(sum%2==0){
            cnt=0
            for(var x=0;x<n;x++){
                if(Number(arr[x])%2==1){
                    cnt=cnt+1;
                }
            }
            if(cnt%2 == 0){
                console.log("NO");
            }
            else{
                console.log("YES")
            }

        }
        else{
            console.log("YES")
        }
    }
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
    read += input;
});
process.stdin.on("end", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
});

process.on("SIGINT", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
    process.exit(0);
});

function runProgram(input){
    input= input.split("\n");
    var t = Number(input[0]);
    for(var i=0;i<t;i++){

        var n = Number(input[2*i+1]);
        var arr = input[2*i+2].split(" ");
        var sum = 0;
        for(var k = 0;k<n;k++){
            sum = sum + Number(arr[k]);
        }
        if(sum%2==0){
            cnt=0
            for(var i=0;i<n;i++){
                if(Number(arr[i])%2==1){
                    cnt=cnt+1;
                }
            }
            if(cnt%2 == 0){
                console.log("NO");
            }
            else{
                console.log("YES")
            }

        }
        else{
            console.log("YES")
        }
    }
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
    read += input;
});
process.stdin.on("end", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
});

process.on("SIGINT", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
    process.exit(0);
});

function runProgram(input){
    input= input.split("\n");
    var t = Number(input[0]);
    for(var i=0;i<t;i++){

        var n = Number(input[2*i+1]);
        var arr = input[2*i+2].split(" ");
        var sum = 0;
        for(var k = 0;k<n;k++){
            sum = sum + Number(arr[k]);
        }
        if(sum%2==0){
            cnt=0
            for(var x=0;x<n;x++){
                if(Number(arr[x])%2==1){
                    cnt=cnt+1;
                }
            }
            if(cnt==n && n%2==1){
                console.log("NO");
            }
            else if(cnt==0){
                console.log("NO")
            }
            else{
                console.log("YES")
            }
        }
        else{
            console.log("YES")
        }
    }
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
let read = "";
process.stdin.on("data", function (input) {
    read += input;
});
process.stdin.on("end", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
});

process.on("SIGINT", function () {
    read = read.replace(/\n$/,"")
    runProgram(read);
    process.exit(0);
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  if (c % 2 !== 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  const sum = arr.reduce((a, b) => a + b, 0);

  if (sum % 2 === 0) {
    console.log('NO');
  }
  else {
    console.log('YES');
  }

  c++;
});

rl.on('close', () => {

});

function processData(input) {
    //Enter your code here
    var data = input.split('\n')
    var tcs = Number(data[0])
    var line =1
    for(let i = 0;i<tcs;i++){
        let len = Number(data[line])
        line++
        let arr = data[line].split(' ').map(a=>parseInt(a))
        line++
        let res = oddSum(len,arr)
        console.log(res)
    }
    function oddSum(len,arr){
        var count = 0
        for(let i = 0;i<len;i++){
            if(arr[i]%2 ==1){
                count++
            }
        }
        if(count % 2 ==1){
            return "YES"
        }
        else{
             return "NO"
        }
    }

}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

'use strict'

let t = parseInt(readline())
while (t --> 0) {
  const n = parseInt(readline())
  let tot = 0
  const arr = readline().split(' ').map(item => tot += parseInt(item))
  print(tot % 2 == 0 ? 'NO' : 'YES')
}

'use strict'

let t = parseInt(readline())
while (t --> 0) {
  const n = parseInt(readline())
  const arr = readline().split(' ').map(item => parseInt(item))

  let tot = 0
  let odd = false
  for (let i in arr) {
    if (arr[i] % 2) odd = true
    tot += parseInt(arr[i])
  }

  print((tot % 2) || (odd &&  (n % 2)) ? 'YES' : 'NO')
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]param
//不明値:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}
function Main() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var N = myconv(next(),1);
        var list = myconv(next(),4);
        if(N == 1){
            if(list[0] % 2 == 0){
                output[i] = "NO";
            }else{
                output[i] = "YES";
            }
        }else{
            var odd = 0;
            var even = 0;
            for(var j = 0; j < N; j++){
                if(list[j] % 2 == 0){
                    even++;
                }else{
                    odd++;
                }
            }
            if(odd % 2 == 1 || (odd % 2 == 0 && even % 2 == 1)){
                output[i] = "YES";
            }else{
                output[i] = "NO";
            }
        }
    }
    myout(myconv(output,9));
}