#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin >> T;
    while(T--){
        ll n,m,t;
        cin>>n>>m>>t;
        ll N=n;

        ll a,b;
        int f=1, lst=0;
        rep(i,m){
            cin>>a>>b;
            n-=(a-lst);
            if(n<=0) f=0;
            n+=(b-a);
            n = min(n,N);
            lst = b;
        }

        n -= (t-lst);
        if(n<=0) f=0;
        if(f) cout<<"Yes"<<el;
        else cout<<"No"<<el;
    
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
struct Edge {
    int to;
    int cost;
    Edge(int t, int c) : to(t), cost(c) {}
};
using edge = struct {
    long long to;
    long long cost;
};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    vector<string> s(3);
    // repeat
    rep(i, 3) cin >> s[i];
    map<char, ll> mp;
    set<char> heads;  // 先頭文字の集合
    rep(i, 3) {
        reverse(s[i].begin(), s[i].end());
        ll co = 1;
        if (i == 2) co = -1;
        for (char c : s[i]) {
            mp[c] += co;
            co *= 10;
        }
        reverse(s[i].begin(), s[i].end());
        heads.insert(s[i][0]);
    }
    if (mp.size() > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    // 全探索
    vector<int> p(10);
    iota(p.begin(), p.end(), 0);
    do {
        int i = 0;
        ll tot = 0;
        for (auto x : mp) {
            char c = x.first;
            ll co = x.second;
            // 先頭０はだめ
            if (p[i] == 0 && heads.count(c)) tot = 1e18;
            tot += co * p[i];
            ++i;
        }
        if (tot == 0) {
            int i = 0;
            for (auto& x : mp) {
                x.second = p[i];
                ++i;
            }
            rep(i, 3) {
                ll x = 0;
                for (char c : s[i]) {
                    x = x * 10 + mp[c];
                }
                cout << x << endl;
            }
            return 0;
        }
    } while (next_permutation(p.begin(), p.end()));
    cout << "UNSOLVABLE" << endl;
    return 0;
}