You are given a matrix $$$a$$$, consisting of $$$3$$$ rows and $$$n$$$ columns. Each cell of the matrix is either free or taken.A free cell $$$y$$$ is reachable from a free cell $$$x$$$ if at least one of these conditions hold:   $$$x$$$ and $$$y$$$ share a side;  there exists a free cell $$$z$$$ such that $$$z$$$ is reachable from $$$x$$$ and $$$y$$$ is reachable from $$$z$$$. A connected component is a set of free cells of the matrix such that all cells in it are reachable from one another, but adding any other free cell to the set violates this rule.You are asked $$$q$$$ queries about the matrix. Each query is the following:   $$$l$$$ $$$r$$$ — count the number of connected components of the matrix, consisting of columns from $$$l$$$ to $$$r$$$ of the matrix $$$a$$$, inclusive. Print the answers to all queries.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10^5$$$) — the number of columns of matrix $$$a$$$. The $$$i$$$-th of the next three lines contains a description of the $$$i$$$-th row of the matrix $$$a$$$ — a string, consisting of $$$n$$$ characters. Each character is either $$$1$$$ (denoting a free cell) or $$$0$$$ (denoting a taken cell). The next line contains an integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. The $$$j$$$-th of the next $$$q$$$ lines contains two integers $$$l_j$$$ and $$$r_j$$$ ($$$1 \le l_j \le r_j \le n$$$) — the description of the $$$j$$$-th query.

Print $$$q$$$ integers — the $$$j$$$-th value should be equal to the number of the connected components of the matrix, consisting of columns from $$$l_j$$$ to $$$r_j$$$ of the matrix $$$a$$$, inclusive.

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i - 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0, fl: false, fr: false }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc
    node.fr = right.fr
    node.fl = left.fl

    if (left.rc & right.lc) {
      node.val--
      let lc = left.fr ? 7 : left.rc,
        rc = right.fl ? 7 : right.lc
      if ((lc === 5 || rc === 5) && (lc & rc) === 5) {
        if (lc === 7) {
          if (node.r <= this.r[left.r]) node.fr = true
        } else if (rc === 7) {
          if (node.l >= this.l[right.l]) node.fl = true
        }
        node.val--
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc, node.fl, node.fr]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)

      let res = [left[0] + right[0], left[1], right[2], left[3], right[4]]
      if (left[2] & right[1]) {
        res[0]--
        let lc = left[4] ? 7 : left[2],
          rc = right[3] ? 7 : right[1]
        if ((lc === 5 || rc === 5) && (lc & rc) === 5) {
          if (lc === 7) {
            if (y <= this.r[mid]) res[4] = true
          } else if (rc === 7) {
            if (x >= this.l[mid + 1]) res[3] = true
          }
          res[0]--
        }
      }
      return res
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0, fl: false, fr: false }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc

    if (left.rc & right.lc) {
      node.val--
      let lc = left.fr ? 7 : left.rc,
        rc = right.fl ? 7 : right.lc
      if ((lc === 5 || rc === 5) && (lc & rc) === 5) {
        if (lc === 7) {
          if (node.r <= this.r[left.r]) node.fr = true
        } else {
          if (node.l >= this.l[right.l]) node.fl = true
        }
        node.val--
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc, node.fl, node.fr]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)

      let res = [left[0] + right[0], left[1], right[2], left[3], right[4]]
      if (left[2] & right[1]) {
        res[0]--
        let lc = left[4] ? 7 : left[2],
          rc = right[3] ? 7 : right[1]
        if ((lc === 5 || rc === 5) && (lc & rc) === 5) {
          if (lc === 7) {
            if (y <= this.r[mid]) res[4] = true
          } else {
            if (x >= this.l[mid + 1]) res[3] = true
          }
          res[0]--
        }
      }
      return res
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0, fl: false, fr: false }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc

    if (left.rc & right.lc) {
      node.val--
      if ((left.rc === 5 || right.lc === 5) && ((left.fr ? 7 : left.rc) & (right.fl ? 7 : right.lc)) === 5) {
        if (left.fr || left.rc === 7) {
          if (node.r <= this.r[left.r]) node.fr = true
        } else {
          if (node.l >= this.l[right.l]) node.fl = true
        }
        node.val--
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc, node.fl, node.fr]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)
      let val = left[0] + right[0]
      if (left[2] & right[1]) {
        val--
        if ((left[2] === 5 || right[1] === 5) && ((left[4] ? 7 : left[2]) & (right[3] ? 7 : right[1])) === 5) {
          if (left[4] || left[2] === 7) {
            if (y <= this.r[mid]) right[4] = true
          } else {
            if (x >= this.l[mid + 1]) left[3] = true
          }
          val--
        }
      }
      return [val, left[1], right[2], left[3], right[4]]
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0 }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc

    if (left.rc & right.lc) {
      node.val--
      if ((left.rc === 5 || right.lc === 5) && (left.rc & right.lc) === 5) {
        if (left.rc === 7) {
          if (node.r <= this.r[left.r]) node.rc = 7
        } else {
          if (node.l >= this.l[right.l]) node.lc = 7
        }
        node.val--
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)
      let val = left[0] + right[0]
      if (left[2] & right[1]) {
        val--
        if ((left[2] === 5 || right[1] === 5) && (left[2] & right[1]) === 5) {
          if (left[2] === 7) {
            if (right[2] <= this.r[left[2]]) right[2] = 7
          } else {
            if (left[1] >= this.l[right[1]]) left[1] = 7
          }
          val--
        }
      }
      return [val, left[1], right[2]]
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0 }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc

    if (left.rc & right.lc) {
      node.val--
      if ((left.rc === 5 || right.lc === 5) && (left.rc & right.lc) === 5) {
        if (left.rc === 7) {
          if (node.r <= this.r[left.r]) node.rc = 7
        } else {
          if (node.l >= this.l[right.l]) node.lc = 7
        }
        node.val--
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)
      let val = left[0] + right[0]
      if (left[2] & right[1]) {
        val--
        if ((left[2] === 5 || right[1] === 5) && (left[2] & right[1]) === 5) {
          if (left[2] === right[1]) val++
          else {
            if (left[2] === 7) {
              if (right[2] <= this.r[left[2]]) right[2] = 7
            } else {
              if (left[1] >= this.l[right[1]]) left[1] = 7
            }
            val--
          }
        }
      }
      return [val, left[1], right[2]]
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()

const fs = require('fs')
const inputs = fs.readFileSync(0, 'utf-8').split('\n')

const bitMap = [0, 1, 1, 1, 1, 2, 1, 1]
class SegTree {
  constructor(nums = [], n = nums.length - 1) {
    this.nums = nums
    this.l = new Array(nums.length).fill(-1)
    this.r = new Array(nums.length).fill(-1)
    for (let i = 0; i < nums.length; i++) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j < nums.length - 1 && nums[j + 1] === 5) j++
        for (let k = i; k < j; k++) this.r[k] = j
        i = j
      }
    }
    for (let i = nums.length - 1; i >= 0; i--) {
      if (nums[i] === 7 && nums[i + 1] === 5) {
        let j = i
        while (j > 0 && nums[j - 1] === 5) j--
        for (let k = i; k > j; k--) this.l[k] = j
        i = j
      }
    }
    this.n = n
    this.root = this._newNode(0, n)
    this._build(this.root)
    this.query = this._query.bind(this, this.root)
  }
  _newNode(l, r, val = 0, left = null, right = null) {
    return { val, l, r, left, right, lc: 0, rc: 0 }
  }
  _build(node = this.root) {
    const { l, r } = node
    if (l === r) {
      node.val = bitMap[this.nums[l]]
      node.lc = this.nums[l]
      node.rc = this.nums[l]
      return
    }
    const mid = Math.floor((l + r) / 2)
    node.left = this._newNode(l, mid)
    node.right = this._newNode(mid + 1, r)
    const { left, right } = node
    this._build(left)
    this._build(right)
    node.val = left.val + right.val

    node.lc = left.lc
    node.rc = right.rc

    if (left.rc & right.lc) {
      node.val--
      if ((left.rc === 5 || right.lc === 5) && (left.rc & right.lc) === 5) {
        if (left.rc === right.lc) node.val++
        else {
          if (left.rc === 7) {
            if (node.r <= this.r[left.r]) node.rc = 7
          } else {
            if (node.l >= this.l[right.l]) node.lc = 7
          }
          node.val--
        }
      }
    }
  }

  _query(node, x, y) {
    if (y < x) return 0
    if (!node) return 0
    const { l, r } = node
    if (l === x && r === y) return [node.val, node.lc, node.rc]

    let mid = Math.floor((l + r) / 2)
    if (y <= mid) return this._query(node.left, x, y)
    else if (x > mid) return this._query(node.right, x, y)
    else {
      let left = this._query(node.left, x, mid),
        right = this._query(node.right, mid + 1, y)
      let val = left[0] + right[0]
      if (left[2] & right[1]) {
        val--
        if ((left[2] === 5 || right[1] === 5) && (left[2] & right[1]) === 5) {
          if (left[2] === right[1]) val++
          else {
            if (left[2] === 7) {
              if (right[2] <= this.r[left[2]]) right[2] = 7
            } else {
              if (left[1] >= this.l[right[1]]) left[1] = 7
            }
            val--
          }
        }
      }
      return [val, left[1], right[2]]
    }
  }
}

function solve(n, m, data, querys) {
  const segTree = new SegTree(data)
  const res = []
  for (let [l, r] of querys) {
    res.push(segTree.query(l - 1, r - 1)[0])
  }

  return res
}

void (function main() {
  const n = Number(inputs[0])
  const strs = inputs.slice(1, 4)
  const data = []
  for (let i = 0; i < n; i++) {
    data[i] = 0
    for (let j = 0; j < 3; j++) {
      data[i] = (data[i] << 1) + Number(strs[j][i])
    }
  }
  const m = Number(inputs[4])
  const querys = inputs.slice(5, m + 5).map(str => str.split(' ').map(Number))

  const res = solve(n, m, data, querys)
  console.log(res.join('\n'))
})()


A positive (strictly greater than zero) integer is called round if it is of the form d00...0. In other words, a positive integer is round if all its digits except the leftmost (most significant) are equal to zero. In particular, all numbers from $$$1$$$ to $$$9$$$ (inclusive) are round.For example, the following numbers are round: $$$4000$$$, $$$1$$$, $$$9$$$, $$$800$$$, $$$90$$$. The following numbers are not round: $$$110$$$, $$$707$$$, $$$222$$$, $$$1001$$$.You are given a positive integer $$$n$$$ ($$$1 \le n \le 10^4$$$). Represent the number $$$n$$$ as a sum of round numbers using the minimum number of summands (addends). In other words, you need to represent the given number $$$n$$$ as a sum of the least number of terms, each of which is a round number.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is a line containing an integer $$$n$$$ ($$$1 \le n \le 10^4$$$).

Print $$$t$$$ answers to the test cases. Each answer must begin with an integer $$$k$$$ — the minimum number of summands. Next, $$$k$$$ terms must follow, each of which is a round number, and their sum is $$$n$$$. The terms can be printed in any order. If there are several answers, print any of them.

function getMul (x){
	var temp =1;
	while(x --){
		temp *=10;
	}
	return temp;
}

var cases =parseInt(readline());

while(cases --){
	var num = readline().split("");

	var sz =num.length;
	var zero =sz -1;
	var cnt =0;
	var ans ="";

	for(var i =0 ; i <sz ; i ++){
		if(num[i] =='0') {
			zero --;
			continue;
		}

		ans +=" " + (parseInt(num[i]) *getMul(zero));
		zero --;
		cnt ++;
	}

	print(cnt);
	print(ans.trim());
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = readline().split("");
  var multi = 1;
  var res = "";
  var counter = 0;
  for (var i = n.length - 1; i >= 0; i--) {
    if (n[i] == "0") {
      multi *= 10;
      continue;
    }
    res = " " + parseInt(n[i]) * multi + res;
    multi *= 10;
    counter++;
  }
  print(counter);
  print(res.trim());
}

function main() {
  const count = readline();
  for (var i = 0; i < count; i++) {
      var view = readline();
      if (isRowColumnView(view)) {
          print(changeViewToExcel(view));
      } else {
          print(changeViewToCR(view));
      }
  }
}

main();

function main() {
    const count = readline();
    for (var i = 0; i < count; i++) {
        var n = readline();
        var nString = "" + n;
        if (n.length === 1) {
            print(1);
            print(n);
            continue;
        }
        if (n.slice(1) == 0) {
            print(1);
            print(n);
            continue;
        }
        var resultArr = [];
        for (var j = 0; j <= nString.length; j++) {
            var ost = nString % +("1" + "0".repeat(j+1));
            if (ost > 0) {
                resultArr.push(ost);
                nString = "" + (nString - ost)
            }
        }
        print(resultArr.length);
        print(resultArr.join(" "));
    }
}

var inputLength = readline();
var input = [];

for(var j=0; j<inputLength; j++ ) {
    input.push(readline());
}

for (var i =0; i< inputLength; i++) {
	var frac = 10, count = 0, result = '';
	while (input[i]) {
		var part = input[i] % frac;
		frac *= 10;
		if(part) {
			count++;
			input[i] -= part;
			result += part + ' ';
		}
	}
	print(count);
    print( result.substr(0, result.length - 1));

}

readline();
function main() {
  var num = readline();
  if (num != null) {
    num.toString();
    var res = [];
    for (var i = 0; i < num.length; i++) {
      if (num[i] != 0) {
        res.push(num[i] + '0'.repeat(num.length - i - 1));
      }
    }
    print(res.length);
    print(...res);
    main();
  }
}
main();

function main() {
  var testCasesNum = +readline();
  for (var i = 0; i < testCasesNum; i++) {
    var x = +readline();
    var counter = 0;
    var nums = [];
    while (x > 0) {
      var next = x % 10;
      if (next > 0) {
        nums.push(next * Math.pow(10, counter));
      }
      x = (x - (x % 10)) / 10;
      counter++;
    }
    print(nums.length);
    print(nums.join(" "));
  }
}
main()

function solve() {
    var n = readline().split("");

    var i
    var answer = []
    for(i=0; i<n.length; i++) {
        if (n[i] !== "0") {
            var rounded = addZeros(n[i], n.length - i - 1)
            answer.push(rounded)
        }
    }

    print(answer.length)
    print(answer.join(' '))
}

function addZeros(n, numZeros) {
    var i
    var temp = n
    for(i=0; i<numZeros; i++) {
        temp += "0"
    }
    return temp
}

var testCases = readInt();
var testCaseNum;
for(testCaseNum=0; testCaseNum<testCases; testCaseNum++) {
  solve()
}

function readIntArray() {
    return readline().split(" ").map(function(x) { return parseInt(x); });
}

function readInt() {
    return parseInt(readline())
}

'use strict';

let t = parseInt(readline(), 10);

while (t--) {
    const str = readline();
    let multipliers = [];
    let n = parseInt(str, 10);
    let pow = str.length - 1;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 9000
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow = pow - 1;
    }

    multipliers.push(remainder);
    multipliers = multipliers.filter(m => m !== 0);
    print(multipliers.length);
    print(multipliers.join(' '));
}

'use strict';

let t = parseInt(readline(), 10);

while (t--) {
    let multipliers = [];
    let n = parseInt(readline(), 10);
    let pow = 4;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 9000
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow = pow - 1;
    }

    multipliers.push(remainder);
    multipliers = multipliers.filter(m => m !== 0);
    print(multipliers.length);
    print(multipliers.join(' '));
}

'use strict';

let t = parseInt(readline(), 10)

while (t--) {
    let n = parseInt(readline(), 10);
    let multipliers = [];
    let pow = 4;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 900
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow--;
    }

    multipliers.push(remainder);
    multipliers = multipliers.filter(m => m !== 0);
    print(multipliers.length);
    print(multipliers.join(" "));
}

    var nCases = parseInt(this.readline());
    for (var i = 0; i < nCases; i++){
        var n = parseInt(this.readline());
        var res = [];
        var mult = 1;
        while (n > 0){
            if (n % 10 !== 0){
                res.splice(0, 0, n % 10 * mult);
            }
            mult *= 10;
            n = Math.floor(n / 10);
        }
        var j = 0;
        var str = ''
        while (j < res.length - 1)
            str += res[j++] + ' ';
        str += res[j] !== undefined ? res[j] + '\n' : '';
        print(res.length + '\n');
        print(str);
    }

function getNonZeroDigits(str) {
	var count = 0
	for (var ch of str)
		if (ch !== "0")
			++count
	return count
}

function getAllRoundNumbers(str) {
	var len = str.length
	for (var i in str)  {
		if (str[i] !== "0") {
			print(((str[i]-'0')*Math.pow(10,len-i-1)), end=" ")
		}
	}
}

var tc = Number(readline())
while(tc--) {
	var str = readline()
	print(getNonZeroDigits(str))
	getAllRoundNumbers(str)
}

let input = require('fs')
    .readFileSync(0, 'ascii')
    .split('\n')
    .filter(line => !/^\s*$/.test(line))
    .map(l => l.split(' ').map(w => parseInt(w)));

let [t, ...ns] = input;

for (n of ns) {
    let k = 1;
    let r = [];
    while (n > 0) {
	if (n % 10)
	    r.push(k * (n % 10));
	k *= 10;
	n = Math.floor(n / 10);
    }
    console.log(r.length);
    console.log(...r);
}

'use strict';

const parseProblem = (line, problem) => {
    if (!problem.T || problem.T === 0) {
        const result = {problem,
            T: parseInt(line),
            isProcessing: true,
            cases: []
        };
        return result;
    }

    const cases = problem.cases;

    if (cases.length === 0 || !cases[cases.length - 1].isProcessing) {
        cases.push({
            t: line
        });
    }

    const isProcessing = cases.length < problem.T;
    problem.isProcessing = isProcessing;

    return problem;
};

const solve = data => {
    const t = data.t;
    let result = [];
    const len = t.length - 1;

    for(let i = len; i >= 0; i--) {
        if(t[i] == 0) continue;

        let res = t[i];
        for(let j = 0; j < (len - i); j++) {
            res += '0';
        }
        result.push(res);
    }

    return result;
}

const solveCases = cases => {
    for (let index = 0; index < cases.length; index++) {
        const result = solve(cases[index]);
        console.log(result.length + '\n' + result.join(' '));
    }
};

const main = () => {
    const readline = require('readline');

    let problem = {
        T: 0,
        cases: [],
        isProcessing: true
    };

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

    rl.on('line', line => {
        problem = parseProblem(line, problem);

        if (!problem.isProcessing) {
            rl.close();
        }
    }).on('close', () => {
        solveCases(problem.cases);
        process.exit(0);
    });
};

if (!module.parent) {
    main();
}

'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(str => str.trim());

    main();
});

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

function main() {
    const n = parseInt(readLine(), 10);
    for(let i =0; i<n; i++){
        let target =  parseInt(readLine(), 10);;
        const nums = [];
        let j = 0;
        while (target>0){
            let s =  Math.pow(10,(target + '').length - 1 ) * parseInt((target + '')[0]);
            target -= s;
            j++;
            nums.push(s);
        }
        console.log(j)
        console.log(nums.join(' '))
    }
    return;
}

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

let tc
let input;
r.on('line', (line) => {
    if (!tc) { tc = line; }
    else  {
         let num = +line;
         let ans = nums(num);
         console.log(ans.length);
         console.log(ans.map(n => ""+n).join(" "));
    }
});

function nums(n)
{
    let arr =[];
    let pow =1;

    while(n > 0)
    {
        let r = n%10;
        if(r != 0)
             arr.push(r*pow);
        pow *= 10;
        n = Math.floor(n/10);
    }
    return arr;
}

var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
        var t = nextInt();
	var output = new Array(2 * t);
	for(var i = 0; i < t; i++){
		var n = next();
		var list = [];
		for(var j = 0; j < n.length; j++){
			var val = myconv(n[j],1);
			if(val % 10 != 0){
				list.push(val * Math.pow(10,n.length - j - 1));
			}
		}
		output[i * 2] = list.length;
		output[i * 2 + 1] = myconv(list,8);
	}
	myout(myconv(output,9));
}

"use strict";
exports.__esModule = true;
var str = "", lines = [], idxLine = 0;
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function (x) { str += x; });
process.stdin.on('end', function () {
    lines = str.trim().split('\n').map(function (x) { return x.trim(); });
    main();
});
function readline() {
    return lines[idxLine++];
}
var print = console.log;
//===============================
//===============================
function repZero(n) {
    var s = "";
    for (var i = 0; i < n; i++) {
        s += "0";
    }
    return s;
}
function main() {
    var t = parseInt(readline());
    for (var _ = 0; _ < t; _++) {
        var s = readline();
        var n = s.length;
        var r = [];
        for (var i = 0; i < n; i++) {
            if (s[i] != '0') {
                r.push("" + s[i] + repZero(n - i - 1));
            }
        }
        print(r.length);
        print(r.join(" "));
    }
}

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

    function foo (data) {
        const arr = Array.from(data).reverse().reduceRight((acc, value, index) => {
            if (value !== '0') {
                acc.push(value * (10**index));
            }
            return acc;
        },  []);
        return [arr.length, arr.join(' ')];

    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount];

        let result = foo(data);
        answer += result[0] +"\n";
        answer += result[1] +"\n";
        testCount++;
    }
    console.log(answer);
})

'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 => string.trim());

    main();
});

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

function main() {
    const n = parseInt(readline());
    const numbers = [];
    for (let i = 0; i < n; i++) {
        numbers.push(parseInt(readline()));
    }

    numbers.forEach(number => {
        const res = [];
        let i = 1;

        while (i <= number) {
            const digit = (parseInt(number / i) % 10);

            if (digit) {
                res.push(digit * i);
            }

            i *= 10;
        }

        console.log(res.length);
        console.log(res.join(' '));
    })
}

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;
  }

  let n = +d;
  const ans = [];
  let power = 1;

  while (n > 0) {
    if (n % 10 > 0) {
      ans.push(n % 10 * power);
    }

    n = Math.floor(n / 10);
    power *= 10;
  }

  console.log(ans.length);
  console.log(ans.join(' '));

  // const ans = [];
  // for (let i = 0; i < d.length; i++) {
  //   if (d[i] === '0') {
  //     continue;
  //   }

  //   let n = d[i];
  //   for (let j = i + 1; j < d.length; j++) {
  //     n = n + '0';
  //   }
  //   ans.push(n);
  // }

  // console.log(ans.length);
  // console.log(ans.join(' '));

  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;
  }

  const ans = [];
  for (let i = 0; i < d.length; i++) {
    if (d[i] === '0') {
      continue;
    }

    let n = d[i];
    for (let j = i + 1; j < d.length; j++) {
      n = n + '0';
    }
    ans.push(n);
  }

  console.log(ans.length);
  console.log(ans.join(' '));

  c++;
});

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let t = parseInt(input[0]);

  for (let i = 1; i <= t; i += 1) {
    const n = input[i];

    if (n.length === 1) console.log(`1\n${n}`);
    else {
      const answer = [];

      let i = 0;
      for (const num of n.split("")) {
        if (num !== "0") answer.push(num.padEnd(n.length - i, "0"));

        i += 1;
      }
      console.log(answer.length);
      console.log(answer.join(" "));
    }
  }
});

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const num = +lines[i+1]

    const strLength = num.toString(10).length
    const arr = num
      .toString(10)
      .split('')
      .map((ch, index) => {
        return ch * Math.pow(10, strLength-index-1)
      })
      .filter(x => x > 0)
    console.log(arr.length)
    console.log(arr.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)
})

function solve(n) {
  const base = 10;
  const result = [];
  let m = 1;
  while (n > 0) {
    const d = (n % base);
    n = (n - d) / base;
    const t = m * d;
    if (t > 0) {
      result.unshift(t);
    }
    m = m * base;
  }
  return result;
}

function main(lines) {
  lines.shift();
  for (const line of lines) {
    let t = line.trim();
    if (line.length > 0) {
      const n = Number(t);
      const result = solve(n);
      console.log(result.length);
      console.log(result.join(' '));
    }
  }
}

async function processLinesFromStream(rs, pf) {
  const content = [];
  rs.setEncoding("utf-8");
  for await (let chunk of rs) {
    content.push(chunk);
  }
  const lines = content.join('').split(/\n/);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

function solve(n) {
  const base = 10;
  const result = [];
  let m = 1;
  while (n > 0) {
    const d = (n % base);
    n = (n - d) / base;
    const t = m * d;
    if (t > 0) {
      result.unshift(t);
    }
    m = m * base;
  }
  return result;
}

function main(lines) {
  lines.shift();
  for (const line of lines) {
    const n = Number(line);
    const result = solve(n);
    console.log(result.length);
    console.log(result.join(' '));
  }
}

function trim_line(s) {
  return s.trim();
}

function has_content(s) {
  return (s.length > 0);
}

async function processLinesFromStream(rs, pf) {
  const chunks = [];
  const encoding = 'utf-8';
  rs.setEncoding(encoding);
  for await (let chunk of rs) {
    chunks.push(chunk);
  }
  const empty = '';
  const newline = /\n/;
  const lines = chunks.join(empty)
                      .split(newline)
                      .map(trim_line)
                      .filter(has_content);
  const result = pf(lines);
  return result;
}

processLinesFromStream(process.stdin, main);

'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.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));
  main();
});

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

function solve(n) {
  let res = [];
  for (let i = 0; i < n.length; i++) {
    if (n[i] == 0) continue;
    let round = n[i] * Math.pow(10, n.length - i - 1);
    res.push(round);
  }
  return res;
}

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let n = readLine();
    // let a = readLine().split(' ').map((val) => parseInt(val));
    let res = solve(n);
    console.log(res.length);
    console.log(res.join(' '));
  }
  //process.stdout.write("hello: ");
}

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    //process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let testCases = +inputs[0];
    let roundNumbers = inputs.slice(1).map(num => Number(num));
    let newRoundNumbers = {};
    while (testCases--) {

        let roundNumber = roundNumbers[testCases];
        let power = 1;
        let arr = [];
        newRoundNumbers[roundNumbers[testCases]] = [];
        while (roundNumber > 0) {
            if (roundNumber % 10 > 0) {
                newRoundNumbers[roundNumbers[testCases]].push((roundNumber % 10) * power);
            }
            roundNumber = Math.floor(roundNumber / 10);
            power *= 10;
        }
        //  newRoundNumbers[roundNumbers[testCases]] = arr;
    }

    for (let row of roundNumbers) {
        console.log(newRoundNumbers[row].length);
        console.log(newRoundNumbers[row].join(' '));
    }

}

'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++];
}
/**
   5
5009
7
9876
10000
10

**/

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

    for(let r=0;r<range;r++) {
        let number = readline();
        let wholeNumber = [];
        let length = number.length;

        for(let i=0;i<length;i++) {
            if(parseInt(number[i])) {
                let n = Math.pow(10 , length - i - 1);
                wholeNumber.push(parseInt(number[i]) * n);
            }
        }

        console.log(wholeNumber.length);
        console.log(wholeNumber.join(" "));
    }

}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let t = parseInt(readLine());
    for (var i = 0; i < t; i++) {
        let ans = [];
        let n = parseInt(readLine());
        let z = n;
        let k = 1;
        while (ans.length != String(n).split('').length) {
            ans.push(z % 10 * k);
            z = Math.floor(z / 10);
            k *= 10;
        }
        ans = ans.filter(v => v > 0)
        console.log(ans.length);
        console.log(ans.join(' '))
    }
}

'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++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {

    let cases = parseInt(readline(), 10);
    for (var X = 0; X < cases; X++) {
      //const [n,k] = readline().split(" ").map(e => parseInt(e));
      let n = parseInt(readline(), 10);
      let numbers = [];
      let i = 0;
      while (n > 0) {
        const mod = n % 10;
        if (mod > 0) {
          numbers.push(mod * (Math.pow(10, i)))
          //numbers.push(mod);
        }

        n = Math.floor(n / 10);
        i++;
      }

      console.log(numbers.length)
      console.log(numbers.join(' '))

    }

}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = readline().split("");
  var multi = 1;
  var res = "";
  for (var i = n.length - 1; i >= 0; i--) {
    if (n[i] == "0") {
      multi *= 10;
      continue;
    }
    res = " " + parseInt(n[i]) * multi + res;
    multi *= 10;
  }
  print(res.trim());
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = readline().split("");
  var multi = 1;
  var res = [""];
  for (var i = n.length - 1; i >= 0; i--) {
    if (n[i] == "0") {
      multi *= 10;
      continue;
    }
    res.push(parseInt(n[i]) * multi);
    multi *= 10;
  }
  print(res.length, "\n");
  res.forEach((val) => print(val));
}

var t = parseInt(readline());
for (var tc = 0; tc < t; tc++) {
  var n = readline().split("");
  var multi = 1;
  var res = "";
  for (var i = n.length - 1; i >= 0; i--) {
    if (n[i] == "0") {
      multi *= 10;
      continue;
    }
    res = " " + parseInt(n[i]) * multi + res;
    multi *= 10;
  }
  print(parseInt(res.trim()));
}

var inputLength = readline();
var input = readline().split(" ").map(x => parseInt(x));
for (var i =0; i< inputLength; i++) {
	var frac = 10, count = 0, result = '';
	while (input[i]) {
		var part = input[i] % frac;
		frac *= 10;
		if(part) {
			count++;
			input[i] -= part;
			result += part + ' ';
		}
	}
	print(count);
    print( result.substr(0, result.length - 1));

}

function main() {
  const int = +readline()
  const arrayInt = int.toString().split('')
  const reversedArrayInt = arrayInt.reverse()

  const parts = []

  reversedArrayInt.map((number, index) => {
    if (number !== '0') {
      parts.push(Number(number + '0'.repeat(index)))
    }
  })

  print(parts.length)
  print(parts.join(' '))
}
main()

function main() {
  const int = readline()
  const arrayInt = int.toString().split('')
  const reversedArrayInt = arrayInt.reverse()

  const parts = []

  reversedArrayInt.map((number, index) => {
    if (number !== '0') {
      parts.push(Number(number + '0'.repeat(index)))
    }
  })

  print(parts.length)
  print(parts)
}
main()

function main() {
  const int = readline()
  const arrayInt = int.toString().split('')
  const reversedArrayInt = arrayInt.reverse()

  const parts = []

  reversedArrayInt.map((number, index) => {
    if (number !== '0') {
      parts.push(Number(number + '0'.repeat(index)))
    }
  })

  print(parts.length)
  print(...parts)
}
main()

function integerParser(int) {
  const arrayInt = int.toString().split('')
  const reversedArrayInt = arrayInt.reverse()

  const parts = []

  reversedArrayInt.map((number, index) => {
    if (number !== '0') {
      parts.push(Number(number + '0'.repeat(index)))
    }
  })

  return parts
}

function main() {
  const int = +readline()
  const arrayInt = int.toString().split('')
  const reversedArrayInt = arrayInt.reverse()

  const parts = []

  reversedArrayInt.map((number, index) => {
    if (number !== '0') {
      parts.push(Number(number + '0'.repeat(index)))
    }
  })

  print(parts.length)
  print(...parts)
}
main()

var num = readline().toString();
var res = [];
for (var i = 0; i < num.length; i++) {
  if (num[i] != 0) {
    res.push(num[i] + '0'.repeat(num.length - i - 1));
  }
}
print(res.length, ...res);

'use strict';

let t = parseInt(readline(), 10);

while (t--) {
    const str = readline();
    let multipliers = [];
    let n = parseInt(str, 10);
    let pow = str.length - 1;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 9000
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow = pow - 1;
    }

    multipliers.push(remainder);
    multipliers = multipliers.filter(m => m !== 0);
    print(multipliers.length);
    print(str, '–', multipliers.join(' '));
}

'use strict';

let t = parseInt(readline(), 10);

while (t--) {
    const str = readline();
    const multipliers = [];
    let n = parseInt(str, 10);
    let pow = str.length - 1;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 9000
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow = pow - 1;
    }

    if (remainder !== 0) {
        multipliers.push(remainder);
    }
    print(multipliers.join(' '));
}

'use strict';

let t = parseInt(readline(), 10);

while (t--) {
    const str = readline();
    const multipliers = [];
    let n = parseInt(str, 10);
    let pow = str.length - 1;
    let remainder = n;

    while (remainder > 9) {
        // 9876 % 1000 = 876
        remainder = n % Math.pow(10, pow);
        // 9876 - 876 = 9000
        multipliers.push(n - remainder);
        // 876
        n = remainder;
        pow = pow - 1;
    }

    if (remainder !== 0) {
        multipliers.push(remainder);
    }
    print(multipliers.length);
    print(multipliers.join(' '));
}

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  let t = parseInt(input[0]);

  for (let i = 1; i <= t; i += 1) {
    const n = input[i];

    if (n.length === 1) console.log(n);
    else {
      const answer = [];

      let i = 0;
      for (const num of n.split("")) {
        if (num !== "0") answer.push(num.padEnd(n.length - i, "0"));

        i += 1;
      }

      console.log(answer.join(" "));
    }
  }
});

'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.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));
  main();
});

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

function solve(n) {
  let res = [];
  for (let i = 0; i < n.length; i++) {
    if (n[i] == 0) continue;
    let round = n[i] * Math.pow(10, n.length - i - 1);
    res.push(round);
  }
  return res;
}

function main() {
  const t = parseInt(readLine());
  for (let i = 0; i < t; i++) {
    let n = readLine();
    // let a = readLine().split(' ').map((val) => parseInt(val));
    let res = solve(n);
    console.log(res.join(' '));
  }
  //process.stdout.write("hello: ");
}

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    //process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split('\n');
    let testCases = +inputs[0];
    let roundNumbers = inputs.slice(1).map(num => Number(num));
    let newRoundNumbers = {};
    while (testCases--) {

        let roundNumber = roundNumbers[testCases];
        let power = 1;
        let arr = [];
        while (roundNumber > 0) {
            if (roundNumber % 10 > 0) {
                arr.push((roundNumber % 10) * power);
            }
            roundNumber = Math.floor(roundNumber / 10);
            power *= 10;
        }
        newRoundNumbers[roundNumbers[testCases]] = arr;
    }

    for (const [key, value] of Object.entries(newRoundNumbers)) {
        console.log(value.length);
        console.log(value.join(' '));
    }
}


Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match  — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$)  — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$).

For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any.

RBR
RRBRBRBRBR
RBRBRBRBRBR
RRRRRBRRRR
RRRBRRRBRR
RRRBRRRBRRR

NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further.

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        var r = parseInt(casos[1]);
        var b = parseInt(casos[2]);
        var toret=''

        while(r>0 || b>0){
            var div= Math.floor(r/(b+1));

            for(let j=0; j<div; j++){
                if(r>0){
                    toret+="R";
                    r--;
                }
            }
            if(b>0){
                toret+="B";
                b--;
            }
        }
        console.log(toret)

    }

}

const solve = (n,r,b)=>{
     let res = "";
     let p = Math.floor(r/(b+1));
     let q = r%(b+1);
     for(let i=0;i<q;i++){
          let t = p+1;
          while(t--) res+="R";
          res+="B";
     }
     for(let i=q;i<b;i++){
          let t = p;
          while(t--) res+="R";
          res+="B";
     }
     while(p--) res+="R";
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

let buf='';

process.stdin.on('readable', function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end', function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let [n,r,b]=line[_].split(' ').map(x=>{return parseInt(x)});
        let x=Math.floor(r/(b+1));
        let y=101;
        if((b+1)*x!==r)
        {
            x++;
            y=r-(x-1)*(b+1);
        }
        let ans='';
        for(let i=1;i<=b;i++)
        {
            let z;
            if(i<=y) z=x;
            else z=x-1;
            for(let j=1;j<=z;j++)
            {
                ans+='R';
                r--;
            }
            ans+='B'
        }
        while(r>0)
        {
            ans+='R';
            r--;
        }
        console.log(ans);
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let [n,r,b]=line[_].split(' ').map(x=>{return parseInt(x)});
        let x=Math.floor(r/(b+1));
        let y=101;
        if((b+1)*x!==r)
        {
            x++;
            y=r-(x-1)*(b+1);
        }
        let ans='';
        for(let i=1;i<=b;i++)
        {
            let z;
            if(i<=y) z=x;
            else z=x-1;
            for(let j=1;j<=z;j++)
            {
                ans+='R';
                r--;
            }
            ans+='B'
        }
        while(r>0)
        {
            ans+='R';
            r--;
        }
        console.log(ans);
    }
})

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    for(let _=1;_<=t;_++)
    {
        let [n,r,b]=line[_].split(' ').map(x=>{return parseInt(x)});
        let x=Math.floor(r/(b+1));
        let y=101;
        if((b+1)*x!==r)
        {
            x++;
            y=r-(x-1)*(b+1);
        }
        // console.log('x=',x,y);
        let ans='';
        for(let i=1;i<=b;i++)
        {
            let z;
            if(i<=y) z=x;
            else z=x-1;
            // console.log('z=',z);
            for(let j=1;j<=z;j++)
            {
                ans+='R';
                r--;
            }
            // ans+='R';
            // for(let j=1;j<=x;j++)
            // {
            //     ans+='B';
            //     b--;
            // }
            ans+='B'
        }
        while(r>0)
        {
            ans+='R';
            r--;
        }
        console.log(ans);
    }
})

const processData = (lines) => {
    let n = +lines[0];
    for (let i=1; i<=n; i++) {
        let [c, r, b] = lines[i].split(' ').map(Number);
        let res = [];
        let divider = r/(b+1);
        let min = 0;

        for (let i=1; i<=r; i++) {
            res.push('R');
            let p = Math.floor(i/divider);
            if (p>min && b>0) {
                res.push('B');
                b--;
            }
            min = p;
        }
        console.log(res.join(''));
    }

}

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

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);

function div(val, by){
    return (val - val % by) / by;
}

const calc = (n, r, b)=>{
    // 10 6 4
    const ratio = Math.floor(r / (b + 1)); // 1
    let over = r - (b + 1) * ratio; // 1
    let matching = r - over;
    const rbigger = new Array(ratio + 1).fill('R').join('');
    const rsmaller = new Array(ratio).fill('R').join('');
    let result = '';

    for (let i = 0; i <= b; i++) {
        if (over) {
            result += rbigger;
            over--;
        } else if (matching) {
            result += rsmaller;
            matching--;
        }
        if (i !== b) {
            result += 'B';
        }
    }
    return result;

    // const ratio = Math.ceil(r / (b + 1));
    // let bigger = Math.floor(r / ratio);
    // let smaller = ratio > 1 ? Math.round((r - bigger * ratio) / (ratio - 1)) : 0;
    // const rbigger = new Array(ratio).fill('R').join('');
    // const rsmaller = ratio > 1 ? new Array(ratio - 1).fill('R').join('') : '';
    // let result = '';
    // let rb = 0;
    // while (result.length < n) {
    //     if (bigger) {
    //         result += rbigger;
    //         bigger--;
    //     } else if (smaller) {
    //         result += rsmaller;
    //         smaller--;
    //     }
    //     if (rb + 1 <= b)  {
    //         result += 'B';
    //         rb++;
    //     }
    // }
    // return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let [n, r, b] = ra();
        console.log(`${calc(n, r, b)}`);
    }
}

const readline = require("readline");

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

class Input {
	constructor(line) {
		this.pointer = -1;
		this.content = [line];
	}
	add(line) {
		this.content.push(line);
	}
	get(line) {
		if (!(this.pointer < this.content.length - 1)) {
			return -1
		}
		return this.content[++this.pointer];
	}
}

const intify = (arr) => {
	if (typeof arr == "string") {
		let temp = "";
		for (let i = 0; i < arr.length; i++) {
			if (arr[i] != ' ') {
				temp += arr[i];
			}
		}
		return parseInt(temp)
	} else {
		return arr.map(ele => parseInt(ele))
	}
}

rl.once("line", line => {
	let inp = new Input(line);
	rl.on("line", line => {
		inp.add(line)
	}).on("close", () => {

		let t = intify(inp.get())
		while (t--) {
			let [n, r, b] = intify(inp.get().split(' '))
			let max = Math.ceil(r / (b + 1));
			let min = Math.floor(r / (b + 1));
			let min_str = "";
			while (min--) {
				min_str += 'R'
			}
			let max_count = r % (b + 1)
			let ans = [];
			let r_str = "";
			while (max--) {
				r_str += 'R'
			}
			for (let i = 0; i < max_count; i++) {
				ans.push(r_str)
				ans.push('B')
			}
			for (let i = 0; i < (b + 1) - max_count - 1; i++) {
				ans.push(min_str)
				ans.push('B')
			}
			ans.push(min_str)
			console.log(ans.join(''))
		}

    });
});

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, r, b] = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, r, b)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, r, b) {
    const d = r - b - 1
    const k = Math.floor(d / (b + 1))
    const rest = d % (b + 1)
    //
    const ans = ['R']
    for (let i = 0; i < b; i++) {
        ans[i + 1] = 'BR'
    }
    for (let i = 0; i < b + 1; i++) {
        ans[i] += Array(i < rest ? k + 1 : k).fill('R').join('')
    }
    return ans.join('')
    // const ca = Math.ceil(d / 2)
    // const cb = Math.floor(d / 2)
    // const la = Array(ca).fill('R')
    // const lb = Array(cb).fill('R')
    // return la.concat(ans.concat(lb)).join('')
}

'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(n, r, b) {
  b++;
  let m = Math.floor(r / b),
      rem = r - m * b;
  let res = '';

  for (let i = 0; i < b; i++) {
    res += 'R'.repeat(m);

    if (rem > 0) {
      rem--;
      res += 'R';
    }

    if (i < b - 1) res += 'B';
  }

  return res;
}

function main(inputs) {
  const _ = Number(inputs[0]);

  for (let __ = 0; __ < _; __++) {
    const [n, r, b] = inputs[__ + 1].trim().split(' ').map(Number);

    const res = solve(n, r, b);
    console.log(res);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split('\n');
main(inputs);

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        var r = parseInt(casos[1]);
        var b = parseInt(casos[2]);
        var toret=''

        while(r>0 && b>0){
            var div= Math.floor(r/(b+1));

            for(let j=0; j<div; j++){
                if(r>0){
                    toret+="R";
                    r--;
                }
            }
            if(b>0){
                toret+="B";
                b--;
            }
        }
        console.log(toret)

    }

}

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        var r = parseInt(casos[1]);
        var b = parseInt(casos[2]);

        while(r>0 && b>0){
            var div= Math.floor(r/(b+1));

            for(let j=0; j<div; j++){
                if(r>0){
                    console.log("R");
                    r--;
                }
            }
            if(b>0){
                console.log("B");
                b--;
            }
        }

    }

}

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        const r = parseInt(casos[1]);
        const b = parseInt(casos[2]);

        var ex=0;
        while(r>0 && b>0 && ex==0){
            var div= Math.floor(r/(b+1));
            console.log(div)
            ex++;
            // for(let j=0; j<div; j++){
            //     if(r>0){
            //         r--;
            //         console.log("R");
            //     }
            // }
            // if(b>0){
            //     console.log("B");
            //     b--;
            // }
        }

    }

}

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        const r = parseInt(casos[1]);
        const b = parseInt(casos[2]);

        var ex=0;
        while(r>0 && b>0 && ex==0){
            var div= Math.floor(r/b+1);
            console.log(div)
            ex++;
            // for(let j=0; j<div; j++){
            //     if(r>0){
            //         r--;
            //         console.log("R");
            //     }
            // }
            // if(b>0){
            //     console.log("B");
            //     b--;
            // }
        }

    }

}

/* Common Template Starts */
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++];
}
/* Common Template Ends */
function main() {

    const numeroCasos = parseInt(readline());
    for (let i = 0; i < numeroCasos; i++) {

        const casos= readline().split(" ");
        const n = parseInt(casos[0]);
        const r = parseInt(casos[1]);
        const b = parseInt(casos[2]);

        console.log("ej"+n+r+b)

        // while(r>0 && b>0){
        //     var div= Math.floor(r/b+1);
        //     for(let j=0; j<div; j++){
        //         if(r>0){
        //             r--;
        //             console.log("R");
        //         }
        //     }
        //     if(b>0){
        //         console.log("B");
        //         b--;
        //     }
        // }

    }

}

const solve = (n,r,b)=>{
     let res = "";
     let regions = b+1,red,red1;
     if((r%(regions-1)!==0)&&(r%regions>r%(regions-1))){
          red = Math.floor(r/(regions-1));
          red1 = r%(regions-1);
          regions--;
     }
     else{
          red = Math.floor(r/(regions));
          red1 = r%regions;
     }
     for(let i=0;i<regions;i++){
          let t = red;
          while(t--) res+="R";
          if(i+1<regions)res+="B";
     }
     while(red1--) res+="R";
     return res;

}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const solve = (n,r,b)=>{
     let res = "";
     let regions = b+1,red,red1;
     if((r%(regions-1)!==0)&&(r%regions>r%(regions-1))){
          red = Math.floor(r/(regions-1));
          red1 = r%(regions-1);
     }
     else{
          red = Math.floor(r/(regions));
          red1 = r%regions;
     }
     for(let i=0;i<regions;i++){
          let t = red;
          while(t--) res+="R";
          if(i+1<regions)res+="B";
     }
     while(red1--) res+="R";
     return res;

}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const solve = (n,r,b)=>{
     let res = "";
     let regions = b+1;
     let red = Math.floor(r/regions);
     for(let i=0;i<regions;i++){
          let t = red;
          while(t--) res+="R";
          if(i+1<regions)res+="B";
     }
     let red1 = r%regions;
     while(red1--) res+="R";
     return res;

}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const calcBluePos = (n,b)=>{
     let pos = 2;
     while(true){
          let t = b*pos;
          if(t>n) return pos-1;
          if(pos>=n-t) return pos;
          pos++;
     }
}
const solve = (n,r,b)=>{
     let pos,res="";
     if(b===1) pos = Math.floor(n/2)+1;
     else pos = calcBluePos(n,b);
     let j=pos;
     for(let i=0;i<n;i++){
          if(((i+1)===pos)&&(b>0)){
               res+="B";
               pos = j+pos;
               b--;
          }
          else res+="R";
     }
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const calcBluePos = (n,b)=>{
     let pos = 2;
     while(true){
          let t = b*pos;
          if(pos>=n-t) return pos;
          pos++;
     }
}
const solve = (n,r,b)=>{
     let pos,res="";
     if(b===1) pos = Math.floor(n/2)+1;
     else pos = calcBluePos(n,b);
     let j=pos;
     for(let i=0;i<n;i++){
          if(((i+1)===pos)&&(b>0)){
               res+="B";
               pos = j+pos;
               b--;
          }
          else res+="R";
     }
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const calcBluePos = (n,b)=>{
     let pos = 2;
     while(true){
          let t = b*pos;
          if(pos>n-t) return pos;
          pos++;
     }
}
const solve = (n,r,b)=>{
     let pos,res="";
     if(b===1) pos = Math.floor(n/2)+1;
     else pos = calcBluePos(n,b);
     let j=pos;
     for(let i=0;i<n;i++){
          if(((i+1)===pos)&&(b>0)){
               res+="B";
               pos = j+pos;
               b--;
          }
          else res+="R";
     }
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const calcBluePos = (n,b)=>{
     let pos = 2;
     while(true){
          let t = b*pos;
          if(pos>n-t) return pos;
          pos++;
     }
}
const solve = (n,r,b)=>{
     let pos,res="";
     if(b===1) pos = Math.floor(n/2);
     else pos = calcBluePos(n,b);
     for(let i=0;i<n;i++){
          if(((i+1)===pos)&&(b>0)){
               res+="B";
               pos+=pos;
               b--;
          }
          else res+="R";
     }
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const calcBluePos = (n,b)=>{
     let pos = 2;
     while(true){
          let t = b*pos;
          if(pos>n-t) return pos;
          pos++;
     }
}
const solve = (n,r,b)=>{
     let pos,res="";
     if(b===1){
          for(let i=0;i<n;i++){
               if(i===Math.floor(n/2)) res+="B";
               else res+="R";
          }
          return res;
     }
     else pos = calcBluePos(n,b);
     for(let i=0;i<n;i++){
          if((i+1)%pos===0) res+="B";
          else res+="R";
     }
     return res;
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let [n,r,b] = readline().trim().split(" ").map(cur=>parseInt(cur));
       console.log(solve(n,r,b));
  }
}
main();

const processData = (lines) => {
    let n = +lines[0];
    for (let i=1; i<=n; i++) {
        let [c, r, b] = lines[i].split(' ').map(Number);
        let res = [];
        let divider = r/b;
        let min = 0;

        for (let i=1; i<=r; i++) {
            res.push('R');
            let p = Math.round(i/divider);
            if (p>min && b>0) {
                res.push('B');
                b--;
            }
            min = p;
        }
        console.log(res.join(''));
    }

}

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

const processData = (lines) => {
    let n = +lines[0];
    for (let i=1; i<=n; i++) {
        let [c, r, b] = lines[i].split(' ').map(Number);
        let res = [];
        let divider = r / (b+1);
        let min = 0;

        for (let i=1; i<=r; i++) {
            res.push('R');
            let p = Math.round(i/divider);
            if (p>min && b>0) {
                res.push('B');
                b--;
            }
            min = p;
        }
        console.log(res.join(''));
    }

}

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

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);

function div(val, by){
    return (val - val % by) / by;
}

const calc = (n, r, b)=>{
    const ratio = Math.ceil(r / (b + 1));
    const rr = new Array(ratio).fill('R').join('');
    let result = '';
    let rc = 0;
    let rb = 0;
    while (result.length < n) {
        if (rc + ratio <= r)  {
            result += rr;
            rc += ratio;
        } else {
            result += new Array(r - rc).fill('R').join('');
            rc += r - rc;
        }
        if (rb + 1 <= b)  {
            result += 'B';
            rb++;
        }
    }
    return result;
};

function main() {
    let T = +readline();
    for (let t = 1; t <= T; t++){
        let [n, r, b] = ra();
        console.log(`${calc(n, r, b)}`);
    }
}


Permutation p is an ordered set of integers p1,   p2,   ...,   pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1,   p2,   ...,   pn.Your task is to find such permutation p of length n, that the group of numbers |p1 - p2|, |p2 - p3|, ..., |pn - 1 - pn| has exactly k distinct elements.

The single line of the input contains two space-separated positive integers n, k (1 ≤ k < n ≤ 105).

Print n integers forming the permutation. If there are multiple answers, print any of them.

NoteBy |x| we denote the absolute value of number x.

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var n = inp[0];
var k = inp[1];

var sign = true;
var res = [];
for(var i=0; i < n-k; i++){
	res.push(i+1);
}
for(var i=0; i < k; i++){
	if (sign){
		res.push(res[n-k+i-1] + (k-i));
	} else {
		res.push(res[n-k+i-1] - (k-i));
	}
	sign = !sign;
}
var resS = "";
for(var i=0; i < n; i++)
	resS += res[i] + " ";
print(resS);

var z = readline().split(' ').map(function (v) {
        return parseInt(v);
    }),
    n = z[0], k = z[1],
    fs = [function (x) {
        return x + 1;
    },
        function (x) {
            return x - 1;
        }],
    r = fs[(k - 1) % 2],
    i, a, b, c, t = [];

for (i = 0, a = 1, b = n; i < k; i++) {
    t.push(a);
    c = fs[i % 2](a);
    a = b;
    b = c;
}
for (i = k; i < n; i++) {
    t.push(b);
    b = r(b)
}

print(t.join(' '));

var nums = readline().split(' ');
var n = parseInt(nums[0]);
var k = parseInt(nums[1]);

var st = 1;
var ed = n - 1 ;
var h = 0;
var res = n;
while(k>1)
{
	h = 1-h;
    if(h==1)
	{
	    res = res + ' ' + st;
		st++;
	}
	else
	{
	    res = res + ' ' + ed;
		ed --;
	}
	k--;
}
if(h==1)
{
    for(var i=st; i<=ed; i++)
	{
	    res = res + ' ' + i;
	}
}
else
{
    for(var i=ed; i>=st; i--)
	{
	    res = res + ' ' + i;
	}
}

print(res);