// Arup Guha
// 6/15/2023
// Solution to SIUCF CP Contest 2 Problem: Zamka
// https://open.kattis.com/problems/zamka

using namespace std;
#include <bits/stdc++.h>

int digits(int n);

int main() {

    // Get input.
    int lo, hi, sum;
    cin >> lo >> hi >> sum;

    int x = -1, y = -1;

    // Try each number.
    for (int i=lo; i<=hi; i++) {

        // Get the sum of digits, skip if not a match.
        int sumD = digits(i);
        if (sumD != sum) continue;

        // This ensures x is lowest solution.
        if (x == -1) x = i;

        // This ensures y is the highest solution.
        y = i;
    }

    // Ta da!
    cout << x << endl;
    cout << y << endl;

    return 0;
}

// Returns the sum of digits of n.
int digits(int n) {

    // Peel off each digit.
    int res = 0;
    while (n > 0) {
        res += n%10;
        n /= 10;
    }

    // This is the sum.
    return res;
}
