#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
const int N=1e6+10,mod=998244353;
typedef long long LL;
int a[20]={0,1,2,3,4,5,6,7,8,9};
map<char,int>mp; 
long long get_num(char s[]){
	if(a[mp[s[1]]]==0)return -1;
	int len=strlen(s+1); 
	long long ans=a[mp[s[1]]];
	for(int i=2;i<=len;i++){
		ans*=10;
		ans+=a[mp[s[i]]];
	}
	return ans;
}
char s1[N],s2[N],s3[N];
int check(){
	long long num1=get_num(s1);
	long long num2=get_num(s2);
	long long num3=get_num(s3);
	if(num1==-1||num2==-1||num3==-1)return 0;
	return (num1+num2==num3); 
}
int tot=0;
int main(){
	scanf("%s%s%s",s1+1,s2+1,s3+1);
	for(int i=1;i<=strlen(s1+1);i++){
		if(!mp.count(s1[i])){
			mp[s1[i]]=tot++;
		}
	}
	for(int i=1;i<=strlen(s2+1);i++){
		if(!mp.count(s2[i])){
			mp[s2[i]]=tot++;
		}
	}
	for(int i=1;i<=strlen(s3+1);i++){
		if(!mp.count(s3[i])){
			mp[s3[i]]=tot++;
		}
	}
	if(mp.size()>10)puts("UNSOLVABLE");
	else{
		int flag=0;
	do{
		if(check()){
			flag=1;
			break;
		}
	}
	while(next_permutation(a,a+10));
	if(flag){
		cout<<get_num(s1)<<endl;
		cout<<get_num(s2)<<endl;
		cout<<get_num(s3);
	}else{
		puts("UNSOLVABLE");
	}
	}
	return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using LD = long double;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> void coutall(T v) { for(auto i = v.begin(); i != --v.end(); i++){cout << *i << " ";} cout << *--v.end() << endl; }
void yes(bool ok = true){ cout << (ok ? "yes" : "no") << endl; }
void Yes(bool ok = true){ cout << (ok ? "Yes" : "No") << endl; }
void YES(bool ok = true){ cout << (ok ? "YES" : "NO") << endl; }
ll myceil(ll a, ll b) { return (a + (b - 1)) / b; }

void Main(){
    int n; cin >> n;
    vi x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    int cnt = 0;
    rep(i, n-1){
        rep3(j, i+1, n-1){
            // -1 <= y[j] - y[i] / x[j] - x[i] <= 1
            if(abs(y[j] - y[i]) <= abs(x[j] - x[i])) cnt++;
        }
    }

    cout << cnt << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}