stringstreamは遅い

ll f(string& s, VI& tbl){
  ll r=0;
  ll L = s.size();
  rep(i,L){
    char c = s[i];
    ll d = c-'a';
    if(tbl[d]==-1)return -1;
    if(i==0 && tbl[d]==0)return -1;
    r*=10;
    r+=tbl[d];
  }
  return r;
}

// too slow
ll f2(string& s, VI& tbl){
  stringstream ss;
  for(char c : s){
    ll d = c-'a';
    if(tbl[d]==-1)return -1;
    ss << tbl[d];
  }
  string t = ss.str();
  if(t[0]=='0')return -1;
  return stoll(t);
}

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

    // input
    VS S(3);
    rep(i,3)cin>>S[i];

    set<char> se;
    rep(i,3){
      for(char c : S[i])se.insert(c);
    }
    if(se.size()>10)no();
    vector<char> chars;
    for(char c : se)chars.push_back(c);
    ll N = chars.size();

    // 文字=>数字を全探索
    VI I = {0,1,2,3,4,5,6,7,8,9};
    VI tbl(26);
    do{
      rep(i,26)tbl[i]=-1;
      rep(i,N){
        char c = chars[i];
        ll d = c-'a';
        tbl[d] = I[i];
      }

      ll a = f2(S[0],tbl); if(a==-1)continue;
      ll b = f2(S[1],tbl); if(b==-1)continue;
      ll c = f2(S[2],tbl); if(c==-1)continue;
      if(a+b==c){
        p(a);
        p(b);
        p(c);
        return 0;
      }
    }while(next_permutation(ALL(I)));
    no();
    
    return 0;
}