#include <bits/stdc++.h>
using namespace std;
vector<long long> v{
    1,   0, 1,
    2,   0, 2,
    3,   0, 3,
    4,   0, 4,
    5,   0, 5,
    6,   0, 6,
    7,   0, 7,
    8,   0, 8,
    9,   0, 9,
    10,  0, 19,
    11,  0, 29,
    12,  0, 39,
    13,  0, 49,
    14,  0, 59,
    15,  0, 69,
    16,  0, 79,
    17,  0, 89,
    18,  0, 99,
    19,  0, 199,
    20,  0, 299,
    21,  0, 399,
    22,  0, 499,
    23,  0, 599,
    24,  0, 699,
    25,  0, 799,
    26,  0, 899,
    27,  0, 999,
    28,  0, 1999,
    29,  0, 2999,
    30,  0, 3999,
    31,  0, 4999,
    32,  0, 5999,
    33,  0, 6999,
    34,  0, 7999,
    35,  0, 8999,
    36,  0, 9999,
    37,  0, 19999,
    38,  0, 29999,
    39,  0, 39999,
    40,  0, 49999,
    41,  0, 59999,
    42,  0, 69999,
    43,  0, 79999,
    44,  0, 89999,
    45,  0, 99999,
    46,  0, 199999,
    47,  0, 299999,
    48,  0, 399999,
    49,  0, 499999,
    50,  0, 599999,
    51,  0, 699999,
    52,  0, 799999,
    53,  0, 899999,
    54,  0, 999999,
    55,  0, 1999999,
    56,  0, 2999999,
    57,  0, 3999999,
    58,  0, 4999999,
    59,  0, 5999999,
    60,  0, 6999999,
    61,  0, 7999999,
    62,  0, 8999999,
    63,  0, 9999999,
    64,  0, 19999999,
    65,  0, 29999999,
    66,  0, 39999999,
    67,  0, 49999999,
    68,  0, 59999999,
    69,  0, 69999999,
    70,  0, 79999999,
    71,  0, 89999999,
    72,  0, 99999999,
    73,  0, 199999999,
    74,  0, 299999999,
    75,  0, 399999999,
    76,  0, 499999999,
    77,  0, 599999999,
    78,  0, 699999999,
    79,  0, 799999999,
    80,  0, 899999999,
    81,  0, 999999999,
    82,  0, 1999999999,
    83,  0, 2999999999,
    84,  0, 3999999999,
    85,  0, 4999999999,
    86,  0, 5999999999,
    87,  0, 6999999999,
    88,  0, 7999999999,
    89,  0, 8999999999,
    90,  0, 9999999999,
    91,  0, 19999999999,
    92,  0, 29999999999,
    93,  0, 39999999999,
    94,  0, 49999999999,
    95,  0, 59999999999,
    96,  0, 69999999999,
    97,  0, 79999999999,
    98,  0, 89999999999,
    99,  0, 99999999999,
    100, 0, 199999999999,
    101, 0, 299999999999,
    102, 0, 399999999999,
    103, 0, 499999999999,
    104, 0, 599999999999,
    105, 0, 699999999999,
    106, 0, 799999999999,
    107, 0, 899999999999,
    108, 0, 999999999999,
    109, 0, 1999999999999,
    110, 0, 2999999999999,
    111, 0, 3999999999999,
    112, 0, 4999999999999,
    113, 0, 5999999999999,
    114, 0, 6999999999999,
    115, 0, 7999999999999,
    116, 0, 8999999999999,
    117, 0, 9999999999999,
    118, 0, 19999999999999,
    119, 0, 29999999999999,
    120, 0, 39999999999999,
    121, 0, 49999999999999,
    122, 0, 59999999999999,
    123, 0, 69999999999999,
    124, 0, 79999999999999,
    125, 0, 89999999999999,
    126, 0, 99999999999999,
    127, 0, 199999999999999,
    128, 0, 299999999999999,
    129, 0, 399999999999999,
    130, 0, 499999999999999,
    131, 0, 599999999999999,
    132, 0, 699999999999999,
    133, 0, 799999999999999,
    134, 0, 899999999999999,
    135, 0, 999999999999999,
    136, 0, 1999999999999999,
    137, 0, 2999999999999999,
    138, 0, 3999999999999999,
    139, 0, 4999999999999999,
    140, 0, 5999999999999999,
    141, 0, 6999999999999999,
    142, 0, 7999999999999999,
    143, 0, 8999999999999999,
    144, 0, 9999999999999999,
    145, 0, 19999999999999999,
    146, 0, 29999999999999999,
    147, 0, 39999999999999999,
    148, 0, 49999999999999999,
    149, 0, 59999999999999999,
    150, 0, 69999999999999999,
    19,  1, 18,
    21,  1, 28,
    23,  1, 38,
    25,  1, 48,
    27,  1, 58,
    29,  1, 68,
    31,  1, 78,
    33,  1, 88,
    35,  1, 98,
    37,  1, 198,
    39,  1, 298,
    41,  1, 398,
    43,  1, 498,
    45,  1, 598,
    47,  1, 698,
    49,  1, 798,
    51,  1, 898,
    53,  1, 998,
    55,  1, 1998,
    57,  1, 2998,
    59,  1, 3998,
    61,  1, 4998,
    63,  1, 5998,
    65,  1, 6998,
    67,  1, 7998,
    69,  1, 8998,
    71,  1, 9998,
    73,  1, 19998,
    75,  1, 29998,
    77,  1, 39998,
    79,  1, 49998,
    81,  1, 59998,
    83,  1, 69998,
    85,  1, 79998,
    87,  1, 89998,
    89,  1, 99998,
    91,  1, 199998,
    93,  1, 299998,
    95,  1, 399998,
    97,  1, 499998,
    99,  1, 599998,
    101, 1, 699998,
    103, 1, 799998,
    105, 1, 899998,
    107, 1, 999998,
    109, 1, 1999998,
    111, 1, 2999998,
    113, 1, 3999998,
    115, 1, 4999998,
    117, 1, 5999998,
    119, 1, 6999998,
    121, 1, 7999998,
    123, 1, 8999998,
    125, 1, 9999998,
    127, 1, 19999998,
    129, 1, 29999998,
    131, 1, 39999998,
    133, 1, 49999998,
    135, 1, 59999998,
    137, 1, 69999998,
    139, 1, 79999998,
    141, 1, 89999998,
    143, 1, 99999998,
    145, 1, 199999998,
    147, 1, 299999998,
    149, 1, 399999998,
    28,  1, 189,
    30,  1, 289,
    32,  1, 389,
    34,  1, 489,
    36,  1, 589,
    38,  1, 689,
    40,  1, 789,
    42,  1, 889,
    44,  1, 989,
    46,  1, 1989,
    48,  1, 2989,
    50,  1, 3989,
    52,  1, 4989,
    54,  1, 5989,
    56,  1, 6989,
    58,  1, 7989,
    60,  1, 8989,
    62,  1, 9989,
    64,  1, 19989,
    66,  1, 29989,
    68,  1, 39989,
    70,  1, 49989,
    72,  1, 59989,
    74,  1, 69989,
    76,  1, 79989,
    78,  1, 89989,
    80,  1, 99989,
    82,  1, 199989,
    84,  1, 299989,
    86,  1, 399989,
    88,  1, 499989,
    90,  1, 599989,
    92,  1, 699989,
    94,  1, 799989,
    96,  1, 899989,
    98,  1, 999989,
    100, 1, 1999989,
    102, 1, 2999989,
    104, 1, 3999989,
    106, 1, 4999989,
    108, 1, 5999989,
    110, 1, 6999989,
    112, 1, 7999989,
    114, 1, 8999989,
    116, 1, 9999989,
    118, 1, 19999989,
    120, 1, 29999989,
    122, 1, 39999989,
    124, 1, 49999989,
    126, 1, 59999989,
    128, 1, 69999989,
    130, 1, 79999989,
    132, 1, 89999989,
    134, 1, 99999989,
    136, 1, 199999989,
    138, 1, 299999989,
    140, 1, 399999989,
    142, 1, 499999989,
    144, 1, 599999989,
    146, 1, 699999989,
    148, 1, 799999989,
    150, 1, 899999989,
    1,   1, 0,
    1,   2, -1,
    1,   3, -1,
    1,   4, -1,
    1,   5, -1,
    1,   6, -1,
    1,   7, -1,
    1,   8, -1,
    1,   9, -1,
    2,   2, -1,
    2,   3, -1,
    2,   4, -1,
    2,   5, -1,
    2,   6, -1,
    2,   7, -1,
    2,   8, -1,
    2,   9, -1,
    3,   1, 1,
    3,   2, 0,
    3,   3, -1,
    3,   4, -1,
    3,   5, -1,
    3,   6, -1,
    3,   7, -1,
    3,   8, -1,
    3,   9, -1,
    4,   2, -1,
    4,   3, -1,
    4,   4, -1,
    4,   5, -1,
    4,   6, -1,
    4,   7, -1,
    4,   8, -1,
    4,   9, -1,
    5,   1, 2,
    5,   2, -1,
    5,   3, -1,
    5,   4, -1,
    5,   5, -1,
    5,   6, -1,
    5,   7, -1,
    5,   8, -1,
    5,   9, -1,
    6,   2, 1,
    6,   3, 0,
    6,   4, -1,
    6,   5, -1,
    6,   6, -1,
    6,   7, -1,
    6,   8, -1,
    6,   9, -1,
    7,   1, 3,
    7,   2, -1,
    7,   3, -1,
    7,   4, -1,
    7,   5, -1,
    7,   6, -1,
    7,   7, -1,
    7,   8, -1,
    7,   9, -1,
    8,   2, -1,
    8,   3, -1,
    8,   4, -1,
    8,   5, -1,
    8,   6, -1,
    8,   7, -1,
    8,   8, -1,
    8,   9, -1,
    9,   1, 4,
    9,   2, 2,
    9,   3, -1,
    9,   4, -1,
    9,   5, -1,
    9,   6, -1,
    9,   7, -1,
    9,   8, -1,
    9,   9, -1,
    10,  1, 9,
    10,  2, -1,
    10,  3, 1,
    10,  4, 0,
    10,  5, -1,
    10,  6, -1,
    10,  7, -1,
    10,  8, -1,
    10,  9, -1,
    11,  1, 5,
    11,  2, -1,
    11,  3, -1,
    11,  4, -1,
    11,  5, -1,
    11,  6, -1,
    11,  7, -1,
    11,  8, -1,
    11,  9, -1,
    12,  1, 19,
    12,  2, 3,
    12,  3, -1,
    12,  4, -1,
    12,  5, -1,
    12,  6, -1,
    12,  7, -1,
    12,  8, -1,
    12,  9, -1,
    13,  1, 6,
    13,  2, -1,
    13,  3, -1,
    13,  4, -1,
    13,  5, -1,
    13,  6, -1,
    13,  7, -1,
    13,  8, -1,
    13,  9, -1,
    14,  1, 29,
    14,  2, -1,
    14,  3, 2,
    14,  4, -1,
    14,  5, -1,
    14,  6, -1,
    14,  7, -1,
    14,  8, -1,
    14,  9, -1,
    15,  1, 7,
    15,  2, 4,
    15,  3, 9,
    15,  4, 1,
    15,  5, 0,
    15,  6, -1,
    15,  7, -1,
    15,  8, -1,
    15,  9, -1,
    16,  1, 39,
    16,  2, -1,
    16,  3, -1,
    16,  4, -1,
    16,  5, -1,
    16,  6, -1,
    16,  7, -1,
    16,  8, -1,
    16,  9, -1,
    17,  1, 8,
    17,  2, -1,
    17,  3, -1,
    17,  4, -1,
    17,  5, -1,
    17,  6, -1,
    17,  7, -1,
    17,  8, -1,
    17,  9, -1,
    18,  1, 49,
    18,  2, 5,
    18,  3, 3,
    18,  4, -1,
    18,  5, -1,
    18,  6, -1,
    18,  7, -1,
    18,  8, -1,
    18,  9, -1,
    19,  1, 18,
    19,  2, -1,
    19,  3, 19,
    19,  4, 9,
    19,  5, -1,
    19,  6, -1,
    19,  7, -1,
    19,  8, -1,
    19,  9, -1,
    20,  1, 59,
    20,  2, -1,
    20,  3, 8,
    20,  4, 2,
    20,  5, -1,
    20,  6, -1,
    20,  7, -1,
    20,  8, -1,
    20,  9, -1,
    21,  1, 28,
    21,  2, 6,
    21,  3, -1,
    21,  4, -1,
    21,  5, 1,
    21,  6, 0,
    21,  7, -1,
    21,  8, -1,
    21,  9, -1,
    22,  1, 69,
    22,  2, -1,
    22,  3, 4,
    22,  4, -1,
    22,  5, -1,
    22,  6, -1,
    22,  7, -1,
    22,  8, -1,
    22,  9, -1,
    23,  1, 38,
    23,  2, -1,
    23,  3, 29,
    23,  4, 8,
    23,  5, -1,
    23,  6, -1,
    23,  7, -1,
    23,  8, -1,
    23,  9, -1,
    24,  1, 79,
    24,  2, 7,
    24,  3, 18,
    24,  4, 19,
    24,  5, 9,
    24,  6, -1,
    24,  7, -1,
    24,  8, -1,
    24,  9, -1,
    25,  1, 48,
    25,  2, -1,
    25,  3, 7,
    25,  4, 3,
    25,  5, -1,
    25,  6, -1,
    25,  7, -1,
    25,  8, -1,
    25,  9, -1,
    26,  1, 89,
    26,  2, -1,
    26,  3, 5,
    26,  4, -1,
    26,  5, -1,
    26,  6, -1,
    26,  7, -1,
    26,  8, -1,
    26,  9, -1,
    27,  1, 58,
    27,  2, 17,
    27,  3, 39,
    27,  4, 7,
    27,  5, 2,
    27,  6, -1,
    27,  7, -1,
    27,  8, -1,
    27,  9, -1,
    28,  1, 189,
    28,  2, -1,
    28,  3, 28,
    28,  4, 18,
    28,  5, -1,
    28,  6, 1,
    28,  7, 0,
    28,  8, -1,
    28,  9, -1,
    29,  1, 68,
    29,  2, -1,
    29,  3, 17,
    29,  4, 29,
    29,  5, -1,
    29,  6, -1,
    29,  7, -1,
    29,  8, -1,
    29,  9, -1,
    30,  1, 289,
    30,  2, 27,
    30,  3, 6,
    30,  4, 4,
    30,  5, 7,
    30,  6, 9,
    30,  7, -1,
    30,  8, -1,
    30,  9, -1,
    31,  1, 78,
    31,  2, -1,
    31,  3, 49,
    31,  4, 6,
    31,  5, -1,
    31,  6, -1,
    31,  7, -1,
    31,  8, -1,
    31,  9, -1,
    32,  1, 389,
    32,  2, -1,
    32,  3, 38,
    32,  4, 17,
    32,  5, -1,
    32,  6, 8,
    32,  7, -1,
    32,  8, -1,
    32,  9, -1,
    33,  1, 88,
    33,  2, 37,
    33,  3, 27,
    33,  4, 28,
    33,  5, 3,
    33,  6, -1,
    33,  7, -1,
    33,  8, -1,
    33,  9, -1,
    34,  1, 489,
    34,  2, -1,
    34,  3, 16,
    34,  4, 39,
    34,  5, -1,
    34,  6, 7,
    34,  7, -1,
    34,  8, -1,
    34,  9, -1,
    35,  1, 98,
    35,  2, -1,
    35,  3, 59,
    35,  4, 5,
    35,  5, -1,
    35,  6, 2,
    35,  7, -1,
    35,  8, -1,
    35,  9, -1,
    36,  1, 589,
    36,  2, 47,
    36,  3, 48,
    36,  4, 16,
    36,  5, 5,
    36,  6, 6,
    36,  7, 1,
    36,  8, 0,
    36,  9, -1,
    37,  1, 198,
    37,  2, -1,
    37,  3, 37,
    37,  4, 27,
    37,  5, -1,
    37,  6, 19,
    37,  7, 9,
    37,  8, -1,
    37,  9, -1,
    38,  1, 689,
    38,  2, -1,
    38,  3, 26,
    38,  4, 38,
    38,  5, -1,
    38,  6, 5,
    38,  7, 8,
    38,  8, -1,
    38,  9, -1,
    39,  1, 298,
    39,  2, 57,
    39,  3, 69,
    39,  4, 49,
    39,  5, 4,
    39,  6, 18,
    39,  7, 7,
    39,  8, -1,
    39,  9, -1,
    40,  1, 789,
    40,  2, -1,
    40,  3, 58,
    40,  4, 15,
    40,  5, -1,
    40,  6, 4,
    40,  7, 6,
    40,  8, -1,
    40,  9, -1,
    41,  1, 398,
    41,  2, -1,
    41,  3, 47,
    41,  4, 26,
    41,  5, -1,
    41,  6, 17,
    41,  7, 5,
    41,  8, -1,
    41,  9, -1,
    42,  1, 889,
    42,  2, 67,
    42,  3, 36,
    42,  4, 37,
    42,  5, 15,
    42,  6, 3,
    42,  7, 4,
    42,  8, -1,
    42,  9, -1,
    43,  1, 498,
    43,  2, -1,
    43,  3, 79,
    43,  4, 48,
    43,  5, -1,
    43,  6, 16,
    43,  7, 3,
    43,  8, -1,
    43,  9, -1,
    44,  1, 989,
    44,  2, -1,
    44,  3, 68,
    44,  4, 59,
    44,  5, -1,
    44,  6, 29,
    44,  7, 2,
    44,  8, -1,
    44,  9, -1,
    45,  1, 598,
    45,  2, 77,
    45,  3, 57,
    45,  4, 25,
    45,  5, 14,
    45,  6, 15,
    45,  7, 19,
    45,  8, 1,
    45,  9, 0,
    46,  1, 1989,
    46,  2, -1,
    46,  3, 46,
    46,  4, 36,
    46,  5, -1,
    46,  6, 28,
    46,  7, 18,
    46,  8, -1,
    46,  9, 1,
    47,  1, 698,
    47,  2, -1,
    47,  3, 89,
    47,  4, 47,
    47,  5, -1,
    47,  6, 14,
    47,  7, 17,
    47,  8, -1,
    47,  9, 2,
    48,  1, 2989,
    48,  2, 87,
    48,  3, 78,
    48,  4, 58,
    48,  5, 25,
    48,  6, 27,
    48,  7, 16,
    48,  8, -1,
    48,  9, 3,
    49,  1, 798,
    49,  2, -1,
    49,  3, 67,
    49,  4, 69,
    49,  5, -1,
    49,  6, 13,
    49,  7, 15,
    49,  8, -1,
    49,  9, 4,
    50,  1, 3989,
    50,  2, -1,
    50,  3, 56,
    50,  4, 35,
    50,  5, -1,
    50,  6, 26,
    50,  7, 14,
    50,  8, -1,
    50,  9, 5,
    51,  1, 898,
    51,  2, 97,
    51,  3, 189,
    51,  4, 46,
    51,  5, 24,
    51,  6, 39,
    51,  7, 13,
    51,  8, -1,
    51,  9, 6,
    52,  1, 4989,
    52,  2, -1,
    52,  3, 88,
    52,  4, 57,
    52,  5, -1,
    52,  6, 25,
    52,  7, 12,
    52,  8, -1,
    52,  9, 7,
    53,  1, 998,
    53,  2, -1,
    53,  3, 77,
    53,  4, 68,
    53,  5, -1,
    53,  6, 38,
    53,  7, 29,
    53,  8, -1,
    53,  9, 8,
    54,  1, 5989,
    54,  2, 197,
    54,  3, 66,
    54,  4, 79,
    54,  5, 35,
    54,  6, 24,
    54,  7, 28,
    54,  8, 11,
    54,  9, 9,
    55,  1, 1998,
    55,  2, -1,
    55,  3, 289,
    55,  4, 45,
    55,  5, -1,
    55,  6, 37,
    55,  7, 27,
    55,  8, -1,
    55,  9, 10,
    56,  1, 6989,
    56,  2, -1,
    56,  3, 188,
    56,  4, 56,
    56,  5, -1,
    56,  6, 23,
    56,  7, 26,
    56,  8, -1,
    56,  9, 11,
    57,  1, 2998,
    57,  2, 297,
    57,  3, 87,
    57,  4, 67,
    57,  5, 34,
    57,  6, 36,
    57,  7, 25,
    57,  8, -1,
    57,  9, 12,
    58,  1, 7989,
    58,  2, -1,
    58,  3, 76,
    58,  4, 78,
    58,  5, -1,
    58,  6, 49,
    58,  7, 24,
    58,  8, -1,
    58,  9, 13,
    59,  1, 3998,
    59,  2, -1,
    59,  3, 389,
    59,  4, 89,
    59,  5, -1,
    59,  6, 35,
    59,  7, 23,
    59,  8, -1,
    59,  9, 14,
    60,  1, 8989,
    60,  2, 397,
    60,  3, 288,
    60,  4, 55,
    60,  5, 45,
    60,  6, 48,
    60,  7, 22,
    60,  8, -1,
    60,  9, 15,
    61,  1, 4998,
    61,  2, -1,
    61,  3, 187,
    61,  4, 66,
    61,  5, -1,
    61,  6, 34,
    61,  7, 39,
    61,  8, -1,
    61,  9, 16,
    62,  1, 9989,
    62,  2, -1,
    62,  3, 86,
    62,  4, 77,
    62,  5, -1,
    62,  6, 47,
    62,  7, 38,
    62,  8, -1,
    62,  9, 17,
    63,  1, 5998,
    63,  2, 497,
    63,  3, 489,
    63,  4, 88,
    63,  5, 44,
    63,  6, 33,
    63,  7, 37,
    63,  8, 21,
    63,  9, 18,
    64,  1, 19989,
    64,  2, -1,
    64,  3, 388,
    64,  4, 189,
    64,  5, -1,
    64,  6, 46,
    64,  7, 36,
    64,  8, -1,
    64,  9, 19,
    65,  1, 6998,
    65,  2, -1,
    65,  3, 287,
    65,  4, 65,
    65,  5, -1,
    65,  6, 59,
    65,  7, 35,
    65,  8, -1,
    65,  9, 20,
    66,  1, 29989,
    66,  2, 597,
    66,  3, 96,
    66,  4, 76,
    66,  5, 55,
    66,  6, 45,
    66,  7, 34,
    66,  8, -1,
    66,  9, 21,
    67,  1, 7998,
    67,  2, -1,
    67,  3, 589,
    67,  4, 87,
    67,  5, -1,
    67,  6, 58,
    67,  7, 33,
    67,  8, -1,
    67,  9, 22,
    68,  1, 39989,
    68,  2, -1,
    68,  3, 488,
    68,  4, 188,
    68,  5, -1,
    68,  6, 44,
    68,  7, 32,
    68,  8, -1,
    68,  9, 23,
    69,  1, 8998,
    69,  2, 697,
    69,  3, 387,
    69,  4, 289,
    69,  5, 54,
    69,  6, 57,
    69,  7, 49,
    69,  8, -1,
    69,  9, 24,
    70,  1, 49989,
    70,  2, -1,
    70,  3, 196,
    70,  4, 75,
    70,  5, -1,
    70,  6, 43,
    70,  7, 48,
    70,  8, -1,
    70,  9, 25,
    71,  1, 9998,
    71,  2, -1,
    71,  3, 689,
    71,  4, 86,
    71,  5, -1,
    71,  6, 56,
    71,  7, 47,
    71,  8, -1,
    71,  9, 26,
    72,  1, 59989,
    72,  2, 797,
    72,  3, 588,
    72,  4, 187,
    72,  5, 65,
    72,  6, 69,
    72,  7, 46,
    72,  8, 31,
    72,  9, 27,
    73,  1, 19998,
    73,  2, -1,
    73,  3, 487,
    73,  4, 288,
    73,  5, -1,
    73,  6, 55,
    73,  7, 45,
    73,  8, -1,
    73,  9, 28,
    74,  1, 69989,
    74,  2, -1,
    74,  3, 296,
    74,  4, 389,
    74,  5, -1,
    74,  6, 68,
    74,  7, 44,
    74,  8, -1,
    74,  9, 29,
    75,  1, 29998,
    75,  2, 897,
    75,  3, 789,
    75,  4, 85,
    75,  5, 64,
    75,  6, 54,
    75,  7, 43,
    75,  8, -1,
    75,  9, 30,
    76,  1, 79989,
    76,  2, -1,
    76,  3, 688,
    76,  4, 186,
    76,  5, -1,
    76,  6, 67,
    76,  7, 42,
    76,  8, -1,
    76,  9, 31,
    77,  1, 39998,
    77,  2, -1,
    77,  3, 587,
    77,  4, 287,
    77,  5, -1,
    77,  6, 53,
    77,  7, 59,
    77,  8, -1,
    77,  9, 32,
    78,  1, 89989,
    78,  2, 997,
    78,  3, 396,
    78,  4, 388,
    78,  5, 75,
    78,  6, 66,
    78,  7, 58,
    78,  8, -1,
    78,  9, 33,
    79,  1, 49998,
    79,  2, -1,
    79,  3, 889,
    79,  4, 489,
    79,  5, -1,
    79,  6, 79,
    79,  7, 57,
    79,  8, -1,
    79,  9, 34,
    80,  1, 99989,
    80,  2, -1,
    80,  3, 788,
    80,  4, 95,
    80,  5, -1,
    80,  6, 65,
    80,  7, 56,
    80,  8, -1,
    80,  9, 35,
    81,  1, 59998,
    81,  2, 1997,
    81,  3, 687,
    81,  4, 286,
    81,  5, 74,
    81,  6, 78,
    81,  7, 55,
    81,  8, 41,
    81,  9, 36,
    82,  1, 199989,
    82,  2, -1,
    82,  3, 496,
    82,  4, 387,
    82,  5, -1,
    82,  6, 64,
    82,  7, 54,
    82,  8, -1,
    82,  9, 37,
    83,  1, 69998,
    83,  2, -1,
    83,  3, 989,
    83,  4, 488,
    83,  5, -1,
    83,  6, 77,
    83,  7, 53,
    83,  8, -1,
    83,  9, 38,
    84,  1, 299989,
    84,  2, 2997,
    84,  3, 888,
    84,  4, 589,
    84,  5, 85,
    84,  6, 63,
    84,  7, 52,
    84,  8, -1,
    84,  9, 39,
    85,  1, 79998,
    85,  2, -1,
    85,  3, 787,
    85,  4, 195,
    85,  5, -1,
    85,  6, 76,
    85,  7, 69,
    85,  8, -1,
    85,  9, 40,
    86,  1, 399989,
    86,  2, -1,
    86,  3, 596,
    86,  4, 386,
    86,  5, -1,
    86,  6, 89,
    86,  7, 68,
    86,  8, -1,
    86,  9, 41,
    87,  1, 89998,
    87,  2, 3997,
    87,  3, 1989,
    87,  4, 487,
    87,  5, 84,
    87,  6, 75,
    87,  7, 67,
    87,  8, -1,
    87,  9, 42,
    88,  1, 499989,
    88,  2, -1,
    88,  3, 988,
    88,  4, 588,
    88,  5, -1,
    88,  6, 88,
    88,  7, 66,
    88,  8, -1,
    88,  9, 43,
    89,  1, 99998,
    89,  2, -1,
    89,  3, 887,
    89,  4, 689,
    89,  5, -1,
    89,  6, 74,
    89,  7, 65,
    89,  8, -1,
    89,  9, 44,
    90,  1, 599989,
    90,  2, 4997,
    90,  3, 696,
    90,  4, 295,
    90,  5, 185,
    90,  6, 87,
    90,  7, 64,
    90,  8, 51,
    90,  9, 45,
    91,  1, 199998,
    91,  2, -1,
    91,  3, 2989,
    91,  4, 486,
    91,  5, -1,
    91,  6, 73,
    91,  7, 63,
    91,  8, -1,
    91,  9, 46,
    92,  1, 699989,
    92,  2, -1,
    92,  3, 1988,
    92,  4, 587,
    92,  5, -1,
    92,  6, 86,
    92,  7, 62,
    92,  8, -1,
    92,  9, 47,
    93,  1, 299998,
    93,  2, 5997,
    93,  3, 987,
    93,  4, 688,
    93,  5, 94,
    93,  6, 189,
    93,  7, 79,
    93,  8, -1,
    93,  9, 48,
    94,  1, 799989,
    94,  2, -1,
    94,  3, 796,
    94,  4, 789,
    94,  5, -1,
    94,  6, 85,
    94,  7, 78,
    94,  8, -1,
    94,  9, 49,
    95,  1, 399998,
    95,  2, -1,
    95,  3, 3989,
    95,  4, 395,
    95,  5, -1,
    95,  6, 188,
    95,  7, 77,
    95,  8, -1,
    95,  9, 50,
    96,  1, 899989,
    96,  2, 6997,
    96,  3, 2988,
    96,  4, 586,
    96,  5, 285,
    96,  6, 84,
    96,  7, 76,
    96,  8, -1,
    96,  9, 51,
    97,  1, 499998,
    97,  2, -1,
    97,  3, 1987,
    97,  4, 687,
    97,  5, -1,
    97,  6, 187,
    97,  7, 75,
    97,  8, -1,
    97,  9, 52,
    98,  1, 999989,
    98,  2, -1,
    98,  3, 896,
    98,  4, 788,
    98,  5, -1,
    98,  6, 83,
    98,  7, 74,
    98,  8, -1,
    98,  9, 53,
    99,  1, 599998,
    99,  2, 7997,
    99,  3, 4989,
    99,  4, 889,
    99,  5, 194,
    99,  6, 186,
    99,  7, 73,
    99,  8, 61,
    99,  9, 54,
    100, 1, 1999989,
    100, 2, -1,
    100, 3, 3988,
    100, 4, 495,
    100, 5, -1,
    100, 6, 289,
    100, 7, 72,
    100, 8, -1,
    100, 9, 55,
    101, 1, 699998,
    101, 2, -1,
    101, 3, 2987,
    101, 4, 686,
    101, 5, -1,
    101, 6, 185,
    101, 7, 89,
    101, 8, -1,
    101, 9, 56,
    102, 1, 2999989,
    102, 2, 8997,
    102, 3, 996,
    102, 4, 787,
    102, 5, 385,
    102, 6, 288,
    102, 7, 88,
    102, 8, -1,
    102, 9, 57,
    103, 1, 799998,
    103, 2, -1,
    103, 3, 5989,
    103, 4, 888,
    103, 5, -1,
    103, 6, 184,
    103, 7, 87,
    103, 8, -1,
    103, 9, 58,
    104, 1, 3999989,
    104, 2, -1,
    104, 3, 4988,
    104, 4, 989,
    104, 5, -1,
    104, 6, 287,
    104, 7, 86,
    104, 8, -1,
    104, 9, 59,
    105, 1, 899998,
    105, 2, 9997,
    105, 3, 3987,
    105, 4, 595,
    105, 5, 294,
    105, 6, 93,
    105, 7, 85,
    105, 8, -1,
    105, 9, 60,
    106, 1, 4999989,
    106, 2, -1,
    106, 3, 1996,
    106, 4, 786,
    106, 5, -1,
    106, 6, 286,
    106, 7, 84,
    106, 8, -1,
    106, 9, 61,
    107, 1, 999998,
    107, 2, -1,
    107, 3, 6989,
    107, 4, 887,
    107, 5, -1,
    107, 6, 389,
    107, 7, 83,
    107, 8, -1,
    107, 9, 62,
    108, 1, 5999989,
    108, 2, 19997,
    108, 3, 5988,
    108, 4, 988,
    108, 5, 485,
    108, 6, 285,
    108, 7, 82,
    108, 8, 71,
    108, 9, 63,
    109, 1, 1999998,
    109, 2, -1,
    109, 3, 4987,
    109, 4, 1989,
    109, 5, -1,
    109, 6, 388,
    109, 7, 189,
    109, 8, -1,
    109, 9, 64,
    110, 1, 6999989,
    110, 2, -1,
    110, 3, 2996,
    110, 4, 695,
    110, 5, -1,
    110, 6, 284,
    110, 7, 188,
    110, 8, -1,
    110, 9, 65,
    111, 1, 2999998,
    111, 2, 29997,
    111, 3, 7989,
    111, 4, 886,
    111, 5, 394,
    111, 6, 387,
    111, 7, 187,
    111, 8, -1,
    111, 9, 66,
    112, 1, 7999989,
    112, 2, -1,
    112, 3, 6988,
    112, 4, 987,
    112, 5, -1,
    112, 6, 193,
    112, 7, 186,
    112, 8, -1,
    112, 9, 67,
    113, 1, 3999998,
    113, 2, -1,
    113, 3, 5987,
    113, 4, 1988,
    113, 5, -1,
    113, 6, 386,
    113, 7, 185,
    113, 8, -1,
    113, 9, 68,
    114, 1, 8999989,
    114, 2, 39997,
    114, 3, 3996,
    114, 4, 2989,
    114, 5, 585,
    114, 6, 489,
    114, 7, 184,
    114, 8, -1,
    114, 9, 69,
    115, 1, 4999998,
    115, 2, -1,
    115, 3, 8989,
    115, 4, 795,
    115, 5, -1,
    115, 6, 385,
    115, 7, 183,
    115, 8, -1,
    115, 9, 70,
    116, 1, 9999989,
    116, 2, -1,
    116, 3, 7988,
    116, 4, 986,
    116, 5, -1,
    116, 6, 488,
    116, 7, 92,
    116, 8, -1,
    116, 9, 71,
    117, 1, 5999998,
    117, 2, 49997,
    117, 3, 6987,
    117, 4, 1987,
    117, 5, 494,
    117, 6, 384,
    117, 7, 289,
    117, 8, 81,
    117, 9, 72,
    118, 2, -1,
    118, 3, 4996,
    118, 4, 2988,
    118, 5, -1,
    118, 6, 487,
    118, 7, 288,
    118, 8, -1,
    118, 9, 73,
    119, 1, 6999998,
    119, 2, -1,
    119, 3, 9989,
    119, 4, 3989,
    119, 5, -1,
    119, 6, 293,
    119, 7, 287,
    119, 8, -1,
    119, 9, 74,
    120, 2, 59997,
    120, 3, 8988,
    120, 4, 895,
    120, 5, 685,
    120, 6, 486,
    120, 7, 286,
    120, 8, -1,
    120, 9, 75,
    121, 1, 7999998,
    121, 2, -1,
    121, 3, 7987,
    121, 4, 1986,
    121, 5, -1,
    121, 6, 589,
    121, 7, 285,
    121, 8, -1,
    121, 9, 76,
    122, 2, -1,
    122, 3, 5996,
    122, 4, 2987,
    122, 5, -1,
    122, 6, 485,
    122, 7, 284,
    122, 8, -1,
    122, 9, 77,
    123, 1, 8999998,
    123, 2, 69997,
    123, 3, 19989,
    123, 4, 3988,
    123, 5, 594,
    123, 6, 588,
    123, 7, 283,
    123, 8, -1,
    123, 9, 78,
    124, 2, -1,
    124, 3, 9988,
    124, 4, 4989,
    124, 5, -1,
    124, 6, 484,
    124, 7, 192,
    124, 8, -1,
    124, 9, 79,
    125, 1, 9999998,
    125, 2, -1,
    125, 3, 8987,
    125, 4, 995,
    125, 5, -1,
    125, 6, 587,
    125, 7, 389,
    125, 8, -1,
    125, 9, 80,
    126, 2, 79997,
    126, 3, 6996,
    126, 4, 2986,
    126, 5, 785,
    126, 6, 393,
    126, 7, 388,
    126, 8, 91,
    126, 9, 81,
    127, 2, -1,
    127, 3, 29989,
    127, 4, 3987,
    127, 5, -1,
    127, 6, 586,
    127, 7, 387,
    127, 8, -1,
    127, 9, 82,
    128, 2, -1,
    128, 3, 19988,
    128, 4, 4988,
    128, 5, -1,
    128, 6, 689,
    128, 7, 386,
    128, 8, -1,
    128, 9, 83,
    129, 2, 89997,
    129, 3, 9987,
    129, 4, 5989,
    129, 5, 694,
    129, 6, 585,
    129, 7, 385,
    129, 8, -1,
    129, 9, 84,
    130, 2, -1,
    130, 3, 7996,
    130, 4, 1995,
    130, 5, -1,
    130, 6, 688,
    130, 7, 384,
    130, 8, -1,
    130, 9, 85,
    131, 2, -1,
    131, 3, 39989,
    131, 4, 3986,
    131, 5, -1,
    131, 6, 584,
    131, 7, 383,
    131, 8, -1,
    131, 9, 86,
    132, 2, 99997,
    132, 3, 29988,
    132, 4, 4987,
    132, 5, 885,
    132, 6, 687,
    132, 7, 292,
    132, 8, -1,
    132, 9, 87,
    133, 2, -1,
    133, 3, 19987,
    133, 4, 5988,
    133, 5, -1,
    133, 6, 493,
    133, 7, 489,
    133, 8, -1,
    133, 9, 88,
    134, 2, -1,
    134, 3, 8996,
    134, 4, 6989,
    134, 5, -1,
    134, 6, 686,
    134, 7, 488,
    134, 8, -1,
    134, 9, 89,
    135, 2, 199997,
    135, 3, 49989,
    135, 4, 2995,
    135, 5, 794,
    135, 6, 789,
    135, 7, 487,
    135, 8, 191,
    135, 9, 90,
    136, 2, -1,
    136, 3, 39988,
    136, 4, 4986,
    136, 5, -1,
    136, 6, 685,
    136, 7, 486,
    136, 8, -1,
    136, 9, 181,
    137, 2, -1,
    137, 3, 29987,
    137, 4, 5987,
    137, 5, -1,
    137, 6, 788,
    137, 7, 485,
    137, 8, -1,
    137, 9, 182,
    138, 2, 299997,
    138, 3, 9996,
    138, 4, 6988,
    138, 5, 985,
    138, 6, 684,
    138, 7, 484,
    138, 8, -1,
    138, 9, 183,
    139, 2, -1,
    139, 3, 59989,
    139, 4, 7989,
    139, 5, -1,
    139, 6, 787,
    139, 7, 483,
    139, 8, -1,
    139, 9, 184,
    140, 2, -1,
    140, 3, 49988,
    140, 4, 3995,
    140, 5, -1,
    140, 6, 593,
    140, 7, 392,
    140, 8, -1,
    140, 9, 185,
    141, 2, 399997,
    141, 3, 39987,
    141, 4, 5986,
    141, 5, 894,
    141, 6, 786,
    141, 7, 589,
    141, 8, -1,
    141, 9, 186,
    142, 2, -1,
    142, 3, 19996,
    142, 4, 6987,
    142, 5, -1,
    142, 6, 889,
    142, 7, 588,
    142, 8, -1,
    142, 9, 187,
    143, 2, -1,
    143, 3, 69989,
    143, 4, 7988,
    143, 5, -1,
    143, 6, 785,
    143, 7, 587,
    143, 8, -1,
    143, 9, 188,
    144, 2, 499997,
    144, 3, 59988,
    144, 4, 8989,
    144, 5, 1985,
    144, 6, 888,
    144, 7, 586,
    144, 8, 291,
    144, 9, 189,
    145, 2, -1,
    145, 3, 49987,
    145, 4, 4995,
    145, 5, -1,
    145, 6, 784,
    145, 7, 585,
    145, 8, -1,
    145, 9, 190,
    146, 2, -1,
    146, 3, 29996,
    146, 4, 6986,
    146, 5, -1,
    146, 6, 887,
    146, 7, 584,
    146, 8, -1,
    146, 9, 281,
    147, 2, 599997,
    147, 3, 79989,
    147, 4, 7987,
    147, 5, 994,
    147, 6, 693,
    147, 7, 583,
    147, 8, -1,
    147, 9, 282,
    148, 2, -1,
    148, 3, 69988,
    148, 4, 8988,
    148, 5, -1,
    148, 6, 886,
    148, 7, 492,
    148, 8, -1,
    148, 9, 283,
    149, 2, -1,
    149, 3, 59987,
    149, 4, 9989,
    149, 5, -1,
    149, 6, 989,
    149, 7, 689,
    149, 8, -1,
    149, 9, 284,
    150, 2, 699997,
    150, 3, 39996,
    150, 4, 5995,
    150, 5, 2985,
    150, 6, 885,
    150, 7, 688,
    150, 8, -1,
    150, 9, 285,
};
inline int digit_sum(long long x) {
  int ans = 0;
  while (x != 0) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
long long precompute[151][10];
bool visited[151][10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < v.size(); i += 3) {
    precompute[v[i]][v[i + 1]] = v[i + 2];
    visited[v[i]][v[i + 1]] = true;
  }
  for (int n = 1; n <= 150; n++) {
    for (int k = 0; k <= 9; k++) {
      if (!visited[n][k]) precompute[n][k] = -1;
    }
  }
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    cout << precompute[n][k] << '\n';
  }
  return 0;
}
