#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001],b[100001];
int main()
{
     int n,k,p,x,y;
     scanf("%d%d%d%d%d",&n,&k,&p,&x,&y);
     int i;
     int sum=0;
     for(i=1;i<=k;i++)
     {
          scanf("%d",&a[i]);
          sum+=a[i];
     }
     sort(a+1,a+1+k);
     int xt=a[k/2],xi=k/2;
     int s=k;
     if(xt<y)
     {
          while(xt<y&&xi<=k)
          {
          	   xi++;
               xt=a[xi];
               s++;
               b[s]=y;
               sum+=y;
          }
          int xtt=n-s;
          for(i=1;i<=xtt;i+=2)
          {
               s++;
               b[s]=y;
               sum+=y;
               s++;
               b[s]=1;
               sum+=1;
          }
          if(i==xtt+2&&xt==y)
          {
          	   s--;
               b[s]=1;
               sum-=y;
          }
          if(sum>x)
               printf("-1\n");
          else
               for(i=k+1;i<=n;i++)
                    printf("%d ",b[i]);
     }
     else
     {
          while(xt>y&&xi<=k)
          {
          	   s++;
          	   b[s]=1;
               xi--;
               xt=a[xi];
               sum+=1;
          }
          if(xt<y)
          {
               xi++;
               xt=a[xi];
               sum-=1;
               s--;
          }
          int xtt=n-s;
          for(i=1;i<=xtt;i+=2)
          {
               s++;
               b[s]=y;
               sum+=y;
               s++;
               b[s]=1;
               sum+=1;
          }
          if(i==xtt+2)
          {
               s--;
               b[s]=1;
               sum-=y;
          }
          if(sum>x)
               printf("-1\n");
          else
               for(i=k+1;i<=n;i++)
                    printf("%d ",b[i]);
     }
     return 0;
}


#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100001],b[100001];
int main()
{
     int n,k,p,x,y;
     scanf("%d%d%d%d%d",&n,&k,&p,&x,&y);
     int i;
     int sum=0;
     for(i=1;i<=k;i++)
     {
          scanf("%d",&a[i]);
          sum+=a[i];
     }
     sort(a+1,a+1+k);
     int xt=a[(k+1)/2],xi=(k+1)/2;
     int s=k;
     if(xt<y)
     {
          while(xt<y&&xi<=k)
          {
          	   if(s%2==0)
			        xi++;
               xt=a[xi];
               s++;
               b[s]=y;
               sum+=y;
          }
          if(xt<y&&xi==k+1&&n-k<k||s>n)
          {
               printf("-1\n");
               return 0;
          }
          int xtt=n-s;
          for(i=1;i<=xtt;i+=2)
          {
               s++;
               b[s]=y;
               sum+=y;
               s++;
               b[s]=1;
               sum+=1;
          }
          if(i==xtt+2&&xt==y)
          {
          	   s--;
               b[s]=1;
               sum-=y;
          }
          if(sum>x)
               printf("-1\n");
          else
               for(i=k+1;i<=n;i++)
                    printf("%d ",b[i]);
     }
     else
     {
          while(xt>y&&xi>0)
          {
          	   s++;
          	   b[s]=1;
          	   if(s%2==1)
		            xi--;
               xt=a[xi];
               sum+=1;
          }
          if(xi==0)
               xt=a[1];
          if(xt<y)
          {
               xi++;
               xt=a[xi];
               sum-=1;
               s--;
          }
          int xtt=n-s;
          for(i=1;i<=xtt;i+=2)
          {
               s++;
               b[s]=y;
               sum+=y;
               s++;
               b[s]=1;
               sum+=1;
          }
          if(i==xtt+2)
          {
               s--;
               b[s]=1;
               sum-=y;
          }
          if(sum>x||s>n)
               printf("-1\n");
          else
               for(i=k+1;i<=n;i++)
                    printf("%d ",b[i]);
     }
     return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    /*if(cnt2>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }*/
    ll sum=0;
    for(i=0;i<k;i++)    sum+=a[i];
    ll sum2= sum + ((n-1)/2 - cnt1) ;

    if(cnt2<(n+1)/2)
        sum2+= ( (n+1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    cnt2 = k-i;
    ll sum=0,sum2;
    for(i=0;i<k;i++)    sum+=a[i];
    if(cnt2>(n+1)/2)
    {
        sum2 = sum + n-cnt2-cnt1;
        if(sum2>x)
            cout<<"-1";
        else
            for(i=0;i<n-cnt2-cnt1;i++)   cout<<"1 ";
        return 0;
    }
    sum2 = sum + ((n-1)/2 - cnt1) ;
    if(cnt2<(n+1)/2)
        sum2+= ( (n+1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    /*if(cnt2>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }*/
    ll sum=0;
    for(i=0;i<k;i++)    sum+=a[i];
    ll sum2= sum + ((n-1)/2 - cnt1) ;

    if(cnt2<(n-1)/2)
        sum2+= ( (n-1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    cnt2 = k-i;
    ll sum=0,sum2;
    for(i=0;i<k;i++)    sum+=a[i];
    if(cnt2>(n+1)/2)
    {
        sum2 = sum + n-cnt2-cnt1;
        if(sum2>x)
            cout<<"-1";
        else
            for(i=0;i<n-cnt2;i++)   cout<<"1 ";
        return 0;
    }
    sum2 = sum + ((n-1)/2 - cnt1) ;
    if(cnt2<(n+1)/2)
        sum2+= ( (n+1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    if(cnt2>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    ll sum=0;
    for(i=0;i<k;i++)    sum+=a[i];
    ll sum2= sum + ((n-1)/2 - cnt1)*1 + ( (n-1)/2 - cnt2)*y;
    if(sum>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    ll sum=0,sum2;
    for(i=0;i<k;i++)    sum+=a[i];
    if(cnt2>(n+1)/2)
    {
        if(cnt1<n-cnt2)
        {
            sum2=sum + n-cnt2;
            if(sum2>x)
                cout<<"-1";
            else
                for(i=0;i<n-cnt2;i++)   cout<<"1 ";
                return 0;
        }
        //return 0;
    }
    sum2= sum + ((n-1)/2 - cnt1) ;
    if(cnt2<(n+1)/2)
        sum2+= ( (n+1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    ll sum=0,sum2;
    for(i=0;i<k;i++)    sum+=a[i];
    if(cnt2>(n+1)/2)
    {
        if(cnt1<n-cnt2)
        {
            sum2+=n-cnt2;
            if(sum2>x)
                cout<<"-1";
            else
                for(i=0;i<n-cnt2;i++)   cout<<"1 ";
                return 0;
        }
        //return 0;
    }
    sum2= sum + ((n-1)/2 - cnt1) ;
    if(cnt2<(n+1)/2)
        sum2+= ( (n+1)/2 - cnt2)*y;

    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,k,p,x,y,a[1000],i,j;
    ios_base::sync_with_stdio(false);
    cin>>n>>k>>p>>x>>y;
    ll cnt1=0,cnt2=0;
    for(i=0;i<k;i++)    cin>>a[i];
    sort(a,a+k);
    i=0;
    while(i<k&&a[i]<y)
    i++;
    cnt1=i;
    if(cnt1>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    i=k-1;
    while(i>=0&&a[i]>=y)
    {
        i--;
        cnt2++;
    }
    if(cnt2>(n-1)/2)
    {
        cout<<"-1";
        return 0;
    }
    ll sum=0;
    for(i=0;i<k;i++)    sum+=a[i];
    ll sum2= sum + ((n-1)/2 - cnt1)*1 + ( (n-1)/2 - cnt2)*y;
    if(sum2>x)
    cout<<"-1";
    else
    {
        for(i=0 ; i<(n-1)/2-cnt1 ; i++)
        cout<<"1 ";
        for(i=0 ; i<=(n-1)/2 - cnt2 ; i++)
        cout<<y<<" ";
    }
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     vector < int > v ;
     for ( int i = 0 ; i < ( n + 1 ) / 2 - tot ; i++ )
     {
         v.push_back ( y ) ;
         sum+= y ;
         k++ ;
     }
     for ( int i = 0 ; i < n - k ; i++ )
     {
         k++;
         v.push_back ( 1 ) ;
         sum++ ;
     }
     if ( sum > x || k > n  )
        return cout << -1 ,0 ;
     for ( int i = 0 ; i < v.size() ; i++ )
        cout << v[i] << " " ;
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ((( n + 1 ) /2) - tot) * y + n - ( ( k - tot )  + ((( n + 1 ) /2)) ) > x )
        return cout << -1 , 0 ;
    int z = ( ( n + 1 ) / 2 ) - tot ;
     for ( int i = 1 ; i <= z ; i++ )
     {
         cout << y << " " ;
         k++ ;
     }
        //cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) ;
     for ( int i = 0 ; i < n - k   ; i++ )
     {
         cout << 1 << " " ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ((( n + 1 ) /2) - tot) * y + n - ( ( k - tot )  + ((( n + 1 ) /2)) ) > x || n - k < (( n + 1 ) /2) - tot )
        return cout << -1 , 0 ;
    int z = ( ( n + 1 ) / 2 ) - tot ;
     for ( int i = 1 ; i <= z ; i++ )
     {
         cout << y << " " ;
         k++ ;
     }
        //cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) ;
     for ( int i = 0 ; i < n - k   ; i++ )
     {
         cout << 1 << " " ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ( n - k ) * p < y )
        return cout << -1 , 0 ;
        cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) ;
     for ( int i = 1 ; i < n - k ; i++ )
     {
         cout << " " << ( x - sum ) / ( n - k ) ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 , ss = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     vector < int > v ;
     for ( int i = 0 ; i < ( n + 1 ) / 2 - tot ; i++ )
     {
         v.push_back ( y ) ;
         sum+= y ;
         k++ ;
     }
     for ( int i = 0 ; i < n - k ; i++ )
     {
         v.push_back ( 1 ) ;
         sum++ ;
         ss++ ;
     }
     if ( sum > x || k + ss > n  )
        return cout << -1 ,0 ;
     for ( int i = 0 ; i < v.size() ; i++ )
        cout << v[i] << " " ;
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ((( n + 1 ) /2) - tot) * y + n - ( k + tot ) > x )
        return cout << -1 , 0 ;
    int z = ( ( n + 1 ) / 2 ) - tot ;
     for ( int i = 1 ; i <= z ; i++ )
     {
         cout << y << " " ;
         k++ ;
     }
        //cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) ;
     for ( int i = 0 ; i < n - k   ; i++ )
     {
         cout << 1 << " " ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ( n - k ) * p < y )
        return cout << -1 , 0 ;
        cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) - 1 ;
     for ( int i = 1 ; i < n - k ; i++ )
     {
         cout << " " << ( x - sum ) / ( n - k ) ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     if ( sum + ( n - k ) > x || sum > x || sum + ((( n + 1 ) /2) - tot) * y + n - ( ( k - tot )  + ((( n + 1 ) /2) - tot) ) > x )
        return cout << -1 , 0 ;
    int z = ( ( n + 1 ) / 2 ) - tot ;
     for ( int i = 1 ; i <= z ; i++ )
     {
         cout << y << " " ;
         k++ ;
     }
        //cout << ( x - sum ) / ( n - k ) + ( x - sum ) % ( n - k ) ;
     for ( int i = 0 ; i < n - k   ; i++ )
     {
         cout << 1 << " " ;
     }
    return 0 ;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
//@soso.es1994
//the_top_coder
const int PI = acos(-1.0) ;
using namespace std ;
const int Max = 10055;
int gcd( int a , int b )
{
    if ( b == 0 )
    return a ;
    else
        return  gcd ( b , a % b ) ;
}
 long long lcm ( long long  a , long long b )
{
    return ( a* ( b / gcd ( a , b ) ) ) ;
}
bool com ( string x , string y )
{
    return x + y < y + x ;
}
int main()
{
     int n , k , x , y , p ;
     long long sum = 0 , tot = 0 ;
     cin >> n >> k >> p >> x >> y ;
     for ( int i = 0 ; i < k ; i++ )
     {
         int s ;
         cin >> s ;
         if ( s >= y )
            tot++ ;
         sum+=s ;
     }
     vector < int > v ;
     for ( int i = 0 ; i < ( n + 1 ) / 2 - tot ; i++ )
     {
         v.push_back ( y ) ;
         sum+= y ;
         k++ ;
     }
     for ( int i = 0 ; i < n - k ; i++ )
     {
         v.push_back ( 1 ) ;
         sum++ ;
     }
     if ( sum > x )
        return cout << -1 ,0 ;
     for ( int i = 0 ; i < v.size() ; i++ )
        cout << v[i] << " " ;
    return 0 ;
}


#include<iostream>
#include<math.h>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstring>
#define M 1000000007
#define ll long long int

using namespace std;

int main(){
int n,k,p,x,y,m,i;
cin>>n>>k>>p>>x>>y;
int temp=0,sum=0;
	for (i=0;i<k;i++) {
		cin >> m;
		temp+=m<y;
		sum+=m;
	}
	int val=min((n-1)/2-temp, n-k);
	if (val<0 || sum+val+(n-k-val)*y>x) {
		cout<<-1<<endl;
	}
	else{
	for (i=0;i<n-k;i++) {
		cout<<(i < val?1:y)<< " ";
	}
	}

return 0;
}


#include<iostream>
#include<math.h>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<cstring>
#define M 1000000007
#define ll long long int

using namespace std;

int a[1002]={0};
vector<int>v;
int main(){
int n,k,p,x,y,i;
cin>>n>>k>>p>>x>>y;

int cnt=0;int minv=1001;int sum=0;
int m=(n+1)/2;
for(i=1;i<=k;i++){
    cin>>a[i];
    sum+=a[i];
    if(a[i]<y) cnt++;
    if(a[i]<minv) minv=a[i];
}
//cout<<cnt<<" "<<minv<<endl;
if(cnt>(n-1)/2) cout<<-1<<endl;
else{
    int v1=max(y,minv);
    int v2=m-(cnt+1);
    for(i=0;i<v2;i++) v.push_back(1);

    int v3=n-m;
    v3=v3-(k-(cnt+1));

    for(i=1;i<=v3;i++){
        v.push_back(v1);
    }
    for(i=0;i<v.size();i++) {
        sum+=v[i];
    }
    if(sum>x) cout<<-1<<endl;
    else{
        for(i=0;i<v.size();i++) cout<<v[i]<<" ";
    }
}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int INF = 1e9;
const int MAXN = 2 * int(1e6) + 5;

int dist[10][10][10][10];
long long ans[10][10];

void bfs(int a, int x, int y) {
    //cout << "x: " << x << "y: " << y << endl;
    queue<int> bfs;
    bfs.push(a);
    dist[a][a][x][y] = 0;
    while(!bfs.empty()) {
        int top = bfs.front();
        //cout << "from: " << a << "to: " << top << "dist: " << dist[a][top][x][y] << endl;
        bfs.pop();
        int newtop1 = (top + x) % 10, newtop2 = (top + y) % 10;
        if (dist[a][newtop1][x][y] == INF) {
            dist[a][newtop1][x][y] = dist[a][top][x][y] + 1;
            bfs.push(newtop1);
        }
        if (dist[a][newtop2][x][y] == INF) {
            dist[a][newtop2][x][y] = dist[a][top][x][y] + 1;
            bfs.push(newtop2);
        }
    }
}

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) for (int k = 0; k < 10; k++) for (int q = 0; q < 10; q++) dist[i][j][k][q] = INF;
    for (int a = 0; a < 10; a++) {
        for(int x = 0; x < 10; x++) {
            for (int y = 0; y < 10; y++) {
                bfs(a, x, y);
            }
        }
    }
    int n = s.size();
    for (int i = 0; i < n - 1; i++) {
        int curd = s[i] - '0';
        int newd = s[i + 1] - '0';
        for (int x = 0; x < 10; x++) {
            for (int y = 0; y < 10; y++) {
                    //cout << "ans: " << i + 2 << "x: " << x << "y: " << y << endl;
                ans[x][y] = ans[x][y] + dist[curd][newd][x][y] - 1;
            //cout << ans[x][y] << endl;
            }
        }
    }
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (ans[i][j] >= INF - 1) cout << -1 << ' ';
            else cout << ans[i][j] << ' ';
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

const int INF = 1e9;
const int MAXN = 2 * int(1e6) + 5;

int dist[10][10][10][10];
long long ans[10][10];

void bfs(int a, int x, int y) {
    //cout << "x: " << x << "y: " << y << endl;
    queue<int> bfs;
    bfs.push(a);
    dist[a][a][x][y] = 0;
    while(!bfs.empty()) {
        int top = bfs.front();
        //cout << "from: " << a << "to: " << top << "dist: " << dist[a][top][x][y] << endl;
        bfs.pop();
        int newtop1 = (top + x) % 10, newtop2 = (top + y) % 10;
        if (dist[a][newtop1][x][y] == INF) {
            dist[a][newtop1][x][y] = dist[a][top][x][y] + 1;
            bfs.push(newtop1);
        }
        if (dist[a][newtop2][x][y] == INF) {
            dist[a][newtop2][x][y] = dist[a][top][x][y] + 1;
            bfs.push(newtop2);
        }
    }
    dist[a][a][x][y] = INF;
    for (int b = 0; b < 10; b++) {
        if (b == a) continue;
        int newtop1 = (b + x) % 10;
        int newtop2 = (b + y) % 10;
        if (newtop1 == 0) dist[a][a][x][y] = min(dist[a][a][x][y], dist[a][b][x][y] + 1);
        if (newtop2 == 0) dist[a][a][x][y] = min(dist[a][a][x][y], dist[a][b][x][y] + 1);
    }
    if (x == 0 && y == 0) {
        dist[a][a][x][y] = 1;
    }
    // cout << "a: " << a << "x: " << x << "y: " << y << ' ' << dist[a][a][x][y] << endl;
}

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) for (int k = 0; k < 10; k++) for (int q = 0; q < 10; q++) dist[i][j][k][q] = INF;
    for (int a = 0; a < 10; a++) {
        for(int x = 0; x < 10; x++) {
            for (int y = 0; y < 10; y++) {
                bfs(a, x, y);
            }
        }
    }
    int n = s.size();
    for (int x = 0; x < 10; ++x) {
        for (int y = 0; y < 10; ++y) {
                long long ans = 0;
            for (int i = 0; i < n - 1; i++) {
                int curd = s[i] - '0';
                int newd = s[i + 1] - '0';
                if (dist[curd][newd][x][y] == INF) {
                    ans = -1;
                    break;
                }
                ans += dist[curd][newd][x][y] - 1;
            }
            cout << ans << ' ';
        }
        cout << endl;
    }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define ll long long
#define Inf 0x3f3f3f3f
#define debug(a) cout<<#a<<"="<<a<<"\n"
using namespace std;
const int mod=1e9+7;
const int maxn=2e6+5;
char s[maxn];
int n,m;
int mx[10];
void init(int x,int y){
	memset(mx,0x3f,sizeof(mx));
	if(x==0&&y==0){
		mx[0]=0;return;
	}
	if(x==0||y==0){
		x=max(x,y);
		for(int i=0;i<=1000;i++){
			if(i%x) continue;
			mx[i%10]=min(mx[i%10],i/x-1);
		}
		return;
	}
	for(int i=0;i<=1000;i++){
		int t=Inf;
		for(int j=0;j*x<=i;j++){
			if((i-x*j)%y==0){
				t=min(t,j+(i-x*j)/y-1);
			}
		}
		mx[i%10]=min(mx[i%10],t);
	}
}
int main()
{
	int T;
	cin>>s+1;
	n=strlen(s+1);
	vector<int>v;
	for(int i=2;i<=n;i++){
		int x=s[i-1]-'0',y=s[i]-'0';
		if(x<=y)  v.push_back(y-x);
		else v.push_back((10+y-x));
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			ll t=0,f=1;
			init(i,j);
			for(int k:v){
				if(mx[k]==Inf){
					f=0;break;
				}
				t+=mx[k];
			}
			if(!f) printf("-1 ");
			else printf("%lld ",t);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define ll long long
#define Inf 0x3f3f3f3f
#define debug(a) cout<<#a<<"="<<a<<"\n"
using namespace std;
const int mod=1e9+7;
const int maxn=2e6+5;
char s[maxn];
int n,m;
int mx[10];
void init(int x,int y){
	memset(mx,0x3f,sizeof(mx));
	if(x==0&&y==0){
		mx[0]=0;return;
	}
	if(x==0||y==0){
		x=max(x,y);
		for(int i=0;i<=99;i++){
			if(i%x) continue;
			mx[i%10]=min(mx[i%10],i/x-1);
		}
		return;
	}
	for(int i=0;i<=99;i++){
		int t=Inf;
		for(int j=0;j*x<=i;j++){
			if((i-x*j)%y==0){
				t=min(t,j+(i-x*j)/y-1);
			}
		}
		mx[i%10]=min(mx[i%10],t);
	}
}
int main()
{
	int T;
	cin>>s+1;
	n=strlen(s+1);
	vector<int>v;
	for(int i=2;i<=n;i++){
		int x=s[i-1]-'0',y=s[i]-'0';
		if(x<=y)  v.push_back(y-x);
		else v.push_back((10+y-x));
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			int t=0,f=1;
			init(i,j);
			for(int k:v){
				if(mx[k]==Inf){
					f=0;break;
				}
				t+=mx[k];
			}
			if(!f) printf("-1 ");
			else printf("%d ",t);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define ll long long
#define Inf 0x3f3f3f3f
#define debug(a) cout<<#a<<"="<<a<<"\n"
using namespace std;
const int mod=1e9+7;
const int maxn=1e6+5;
char s[maxn];
int n,m;
int mx[10];
void init(int x,int y){
	memset(mx,0x3f,sizeof(mx));
	if(x==0&&y==0){
		mx[0]=0;return;
	}
	if(x==0||y==0){
		x=max(x,y);
		for(int i=0;i<=99;i++){
			if(i%x) continue;
			mx[i%10]=min(mx[i%10],i/x-1);
		}
		return;
	}
	for(int i=0;i<=99;i++){
		int t=Inf;
		for(int j=0;j*x<=i;j++){
			if((i-x*j)%y==0){
				t=min(t,j+(i-x*j)/y);
			}
		}
		mx[i%10]=min(mx[i%10],t-1);
	}
}
int main()
{
	int T;
	cin>>s+1;
	n=strlen(s+1);
	vector<int>v;
	for(int i=2;i<=n;i++){
		int x=s[i-1]-'0',y=s[i]-'0';
		if(x<=y)  v.push_back(y-x);
		else v.push_back((10+y-x));
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			int t=0,f=1;
			init(i,j);
			for(int k:v){
				if(mx[k]==Inf){
					f=0;break;
				}
				t+=mx[k];
			}
			if(!f) printf("-1 ");
			else printf("%d ",t);
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define ll long long
#define Inf 0x3f3f3f3f
#define debug(a) cout<<#a<<"="<<a<<"\n"
using namespace std;
const int mod=1e9+7;
const int maxn=2e6+5;
char s[maxn];
int n,m;
int g[10][10];
int solve(int x,int y){
	memset(g,0x3f,sizeof(g));
	for(int i=0;i<10;i++){
		g[i][(i+x)%10]=1;
		g[i][(i+y)%10]=1;
	}
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(g[i][k]!=Inf&&g[k][j]!=Inf){
					g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
				}
			}
		}
	}
	int ans=0;
	for(int i=2;i<=n;i++){
		int l=s[i-1]-'0',r=s[i]-'0';
		if(g[l][r]==Inf) return -1;
		ans+=g[l][r]-1;
	}
	return ans;
}
int main()
{
	int T;
	cin>>s+1;
	n=strlen(s+1);
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			printf("%d ",solve(i,j));
		}
		printf("\n");
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls rt<<1
#define rs rt<<1|1
#define fi first
#define se second
#define ll long long
#define Inf 0x3f3f3f3f
#define debug(a) cout<<#a<<"="<<a<<"\n"
using namespace std;
const int mod=1e9+7;
const int maxn=1e6+5;
char s[maxn];
int n,m;
int mx[10];
void init(int x,int y){
	memset(mx,0x3f,sizeof(mx));
	if(x==0&&y==0){
		mx[0]=0;return;
	}
	if(x==0||y==0){
		x=max(x,y);
		for(int i=0;i<=99;i++){
			if(i%x) continue;
			mx[i%10]=min(mx[i%10],i/x-1);
		}
		return;
	}
	for(int i=0;i<=99;i++){
		int t=Inf;
		for(int j=0;j*x<=i;j++){
			if((i-x*j)%y==0){
				t=min(t,j+(i-x*j)/y-1);
			}
		}
		mx[i%10]=min(mx[i%10],t);
	}
}
int main()
{
	int T;
	cin>>s+1;
	n=strlen(s+1);
	vector<int>v;
	for(int i=2;i<=n;i++){
		int x=s[i-1]-'0',y=s[i]-'0';
		if(x<=y)  v.push_back(y-x);
		else v.push_back((10+y-x));
	}
	for(int i=0;i<=9;i++){
		for(int j=0;j<=9;j++){
			int t=0,f=1;
			init(i,j);
			for(int k:v){
				if(mx[k]==Inf){
					f=0;break;
				}
				t+=mx[k];
			}
			if(!f) printf("-1 ");
			else printf("%d ",t);
		}
		printf("\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long bfs(int a, int b, int x, int y)
{
	if (a == b)
		return 0;

	bool visited[10] = { false };

	queue<pair<int, int> > q;
	q.push(make_pair(a, 0));
	while (!q.empty())
	{
		pair<int, int> p = q.front();
		q.pop();
		if (p.first == b)
			return p.second - 1;
		if (p.second == 1000)
			continue;

		visited[p.first] = 1;
		if(!visited[(p.first+x)%10])
			q.push(make_pair((p.first + x) % 10, p.second + 1));
		if(x!=y && !visited[(p.first+y)%10])
			q.push(make_pair((p.first + y) % 10, p.second + 1));
	}

	return INF;
}

int main()
{
	long long dp[10][10][10][10] = { 0 };
	for (int a = 0; a < 10; a++)
		for (int b = 0; b < 10; b++)
			for (int x = 0; x < 10; x++)
				for (int y = x; y < 10; y++)
					dp[a][b][x][y] = dp[a][b][y][x] = bfs(a, b, x, y);

	char c[2000010];
	scanf("%s", c);
	string s = c;

	long long ans[10][10] = { 0 };
	for (int i = 0; i < s.size() - 1; i++)
	{
		for (int x = 0; x < 10; x++)
		{
			for (int y = 0; y < 10; y++)
			{
				if (ans[x][y] == INF)
					continue;
				long long steps = dp[s[i] - '0'][s[i + 1] - '0'][x][y];
				if (steps == INF)
					ans[x][y] = INF;
				else
					ans[x][y] += steps;
			}
		}
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
			cout << ((ans[i][j]==INF)?-1:ans[i][j]) << ' ';
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long bfs(long long a, long long b, long long x, long long y)
{
	bool visited[10] = { false };

	queue<pair<long long, long long> > q;
	q.push(make_pair((a + x) % 10, 1));
	q.push(make_pair((a + y) % 10, 1));
	while (!q.empty())
	{
		pair<long long, long long> p = q.front();
		q.pop();
		if (p.first == b)
			return p.second - 1;
		if (p.second == 100)
			continue;

		visited[p.first] = 1;

		if(!visited[(p.first+x)%10])
			q.push(make_pair((p.first + x) % 10, p.second + 1));
		if(x!=y && !visited[(p.first+y)%10])
			q.push(make_pair((p.first + y) % 10, p.second + 1));
	}

	return INF;
}

int main()
{
	long long dp[10][10][10][10] = { 0 };
	for (long long a = 0; a < 10; a++)
		for (long long b = 0; b < 10; b++)
			for (long long x = 0; x < 10; x++)
				for (long long y = 0; y < 10; y++)
					dp[a][b][x][y] = bfs(a, b, x, y);

	string s;
	cin >> s;

	long long ans[10][10] = { 0 };
	for (long long i = 0; i < s.size() - 1; i++)
	{
		for (long long x = 0; x < 10; x++)
		{
			for (long long y = 0; y < 10; y++)
			{
				if (ans[x][y] == INF)
					continue;
				long long steps = dp[s[i] - '0'][s[i + 1] - '0'][x][y];
				if (steps == INF)
					ans[x][y] = INF;
				else
					ans[x][y] += steps;
			}
		}
	}

	for (long long i = 0; i < 10; i++)
	{
		for (long long j = 0; j < 10; j++)
			cout << ((ans[i][j]==INF)?-1:ans[i][j]) << ' ';
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long bfs(long long a, long long b, long long x, long long y)
{
	if (a == b)
		return 0;

	bool visited[10] = { false };

	queue<pair<long long, long long> > q;
	q.push(make_pair(a, 0));
	while (!q.empty())
	{
		pair<long long, long long> p = q.front();
		q.pop();
		if (p.first == b)
			return p.second - 1;
		if (p.second == 10000)
			continue;

		visited[p.first] = 1;
		if(!visited[(p.first+x)%10])
			q.push(make_pair((p.first + x) % 10, p.second + 1));
		if(x!=y && !visited[(p.first+y)%10])
			q.push(make_pair((p.first + y) % 10, p.second + 1));
	}

	return INF;
}

int main()
{
	long long dp[10][10][10][10] = { 0 };
	for (long long a = 0; a < 10; a++)
		for (long long b = 0; b < 10; b++)
			for (long long x = 0; x < 10; x++)
				for (long long y = 0; y < 10; y++)
					dp[a][b][x][y] = bfs(a, b, x, y);

	string s;
	cin >> s;

	long long ans[10][10] = { 0 };
	for (long long i = 0; i < s.size() - 1; i++)
	{
		for (long long x = 0; x < 10; x++)
		{
			for (long long y = 0; y < 10; y++)
			{
				if (ans[x][y] == INF)
					continue;
				long long steps = dp[s[i] - '0'][s[i + 1] - '0'][x][y];
				if (steps == INF)
					ans[x][y] = INF;
				else
					ans[x][y] += steps;
			}
		}
	}

	for (long long i = 0; i < 10; i++)
	{
		for (long long j = 0; j < 10; j++)
			cout << ((ans[i][j]==INF)?-1:ans[i][j]) << ' ';
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long bfs(int a, int b, int x, int y)
{
	if (a == b)
		return 0;

	queue<pair<int, int> > q;
	q.push(make_pair(a, 0));
	while (!q.empty())
	{
		pair<int, int> p = q.front();
		q.pop();
		if (p.first == b)
			return p.second - 1;
		if (p.second == 9)
			continue;
		q.push(make_pair((p.first + x) % 10, p.second + 1));
		if(x!=y)
			q.push(make_pair((p.first + y) % 10, p.second + 1));
	}

	return INF;
}

int main()
{
	long long dp[10][10][10][10] = { 0 };
	for (int a = 0; a < 10; a++)
		for (int b = 0; b < 10; b++)
			for (int x = 0; x < 10; x++)
				for (int y = x; y < 10; y++)
					dp[a][b][x][y] = dp[a][b][y][x] = bfs(a, b, x, y);

	char c[2000010];
	scanf("%s", c);
	string s = c;

	long long ans[10][10] = { 0 };
	for (int i = 0; i < s.size() - 1; i++)
	{
		for (int x = 0; x < 10; x++)
		{
			for (int y = 0; y < 10; y++)
			{
				if (ans[x][y] == INF)
					continue;
				long long steps = dp[s[i] - '0'][s[i + 1] - '0'][x][y];
				if (steps == INF)
					ans[x][y] = INF;
				else
					ans[x][y] += steps;
			}
		}
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
			cout << ((ans[i][j]==INF)?-1:ans[i][j]) << ' ';
		cout << endl;
	}

	return 0;
}


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

int dp[10][10][10][10];

void solve(int start, int reach, int a, int b, int moves)
{
	if (moves > 10)
		return;

	if (dp[start][reach][a][b] <= moves)
		return;
	dp[start][reach][a][b] = moves;

	solve(start, (reach + a) % 10, a, b, moves + 1);
	solve(start, (reach + b) % 10, a, b, moves + 1);
}

int main()
{
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			for (int k = 0; k < 10; k++)
				for (int h = 0; h < 10; h++)
					dp[i][j][k][h] = 1000;

	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			for (int k = 0; k < 10; k++)
				solve(i, i, j, k, 0);

	string s;
	cin >> s;

	int ans[10][10] = { 0 };
	bool isok = true;
	for (int i = 1; i < s.size(); i++)
	{
		for (int a = 0; a < 10; a++)
		{
			for (int b = 0; b < 10; b++)
			{
				if (ans[a][b] == -1)
					continue;

				if (dp[s[i - 1] - '0'][s[i] - '0'][a][b] != 1000)
					ans[a][b] += dp[s[i - 1] - '0'][s[i] - '0'][a][b] - 1;
				else
					ans[a][b] = -1;
			}
		}
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
			cout << (j != 0 ? " " : "") << ans[i][j];
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;

long long bfs(int a, int b, int x, int y)
{
	if (a == b)
		return 0;

	bool visited[10] = { false };

	queue<pair<int, int> > q;
	q.push(make_pair(a, 0));
	while (!q.empty())
	{
		pair<int, int> p = q.front();
		q.pop();
		if (p.first == b)
			return p.second - 1;
		if (p.second == 1000)
			continue;

		visited[p.first] = 1;
		if(!visited[(p.first+x)%10])
			q.push(make_pair((p.first + x) % 10, p.second + 1));
		if(x!=y && !visited[(p.first+y)%10])
			q.push(make_pair((p.first + y) % 10, p.second + 1));
	}

	return INF;
}

int main()
{
	long long dp[10][10][10][10] = { 0 };
	for (int a = 0; a < 10; a++)
		for (int b = 0; b < 10; b++)
			for (int x = 0; x < 10; x++)
				for (int y = 0; y < 10; y++)
					dp[a][b][x][y] = bfs(a, b, x, y);

	string s;
	cin >> s;

	long long ans[10][10] = { 0 };
	for (int i = 0; i < s.size() - 1; i++)
	{
		for (int x = 0; x < 10; x++)
		{
			for (int y = 0; y < 10; y++)
			{
				if (ans[x][y] == INF)
					continue;
				long long steps = dp[s[i] - '0'][s[i + 1] - '0'][x][y];
				if (steps == INF)
					ans[x][y] = INF;
				else
					ans[x][y] += steps;
			}
		}
	}

	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
			cout << ((ans[i][j]==INF)?-1:ans[i][j]) << ' ';
		cout << endl;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    if(n1 == n2 and (s1 == 0 or s2 == 0))return 0;
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] =marked[v] + 1;
            if(marked[v] == -1)marked[neighbor1] = 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            if(marked[v] == -1)marked[neighbor2] =1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    //if(s[1] == '6')cout << "the size is" <<s.size()<<endl;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           long long sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += max(0,(Distance(s[m] -'0' , s[m+1] - '0', i, j) -1));

           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    //if(s[1] == '6')cout << "the size is" <<s.size()<<endl;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           long long sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += (Distance(s[m] -'0' , s[m+1] - '0', i, j) -1);

               int a =10;
           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int Distance(int n1,int n2,int s1,int s2){
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    return marked[n2];
}
int main() {
    char n1,n2,n3,n4;
    cin >> n1 >> n2 >> n3 >> n4;

    int N1 = n1 - '0',N2 = n2 - '0' ,N3 = n3 - '0' , N4= n4 -'0';
    for(int i = 0 ; i<10;i++){
        for(int j = 0 ; j<10 ;j++){
            int D1 = Distance(N1, N2, i,j);
            int D2 = Distance(N2 , N3, i,j);
            int D3 = Distance(N3 , N4,i,j);
            if(D1 == -1 or D2 == -1 or D3 == -1 )
                cout << -1 << " ";
            else cout << D1 + D2 + D3 -3 <<" ";
        }
        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    if(s[1] == '6')cout << "the size is" <<s.size()<<endl;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           int sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += (Distance(s[m] -'0' , s[m+1] - '0', i, j) -1);

               int a =10;
           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    //if(s[1] == '6')cout << "the size is" <<s.size()<<endl;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           long long sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += max(0,(Distance(s[m] -'0' , s[m+1] - '0', i, j) -1));

           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    //if(s[1] == '6')cout << "the size is" <<s.size()<<endl;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           long long sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += max(0,(Distance(s[m] -'0' , s[m+1] - '0', i, j) -1));

           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           int sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += Distance(s[m] -'0' , s[m+1] - '0', i, j) -1;
               int a =10;
           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
int dp[10][10];
int Distance(int n1,int n2,int s1,int s2){
    //if(dp[n1][n2] > -2)return dp[n1][n2];
    queue<int> q;
    int marked[10];
    memset(marked,-1,sizeof(marked));
    marked[n1] = 0;
    q.push(n1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        int neighbor1 = (v + s1) % 10;
        int neighbor2 = (v + s2) % 10;
        if(marked[neighbor1]  == -1){
            marked[neighbor1] = marked[v] + 1;
            q.push(neighbor1);
        }
        if(marked[neighbor2] == -1){
            marked[neighbor2] = marked[v] + 1;
            q.push(neighbor2);
        }
    }
    for(int i = 0 ; i<10;i++){
        dp[n1][i] = marked[i] ;
    }
    return marked[n2] ;
}
int main() {
    string s;
    cin >> s;
    for(int i = 0 ;i<10 ;i++){
        for(int j = 0 ; j<10 ; j++){
           memset(dp,-2,sizeof(dp));
           int sum = 0;
           int isConnected = 1;
           for(int m = 0; m <s.size() -1 ;m++){
               if(Distance(s[m]- '0' , s[m+1] -'0', i,j) == -1){
                   isConnected = 0;
                   break;
               }
               sum += Distance(s[m] -'0' , s[m+1] - '0', i, j) -1;
               int a =10;
           }
           if(isConnected )cout << sum << " ";
           else cout << -1  << " ";
        }

        cout << endl;
    }
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 19
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int cnt[10][10];
int main()
{
    fast;
    string s;
    cin>>s;
    int arr[10][10][10],tmp,n,ans;
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            for(int x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            for(int x=0; x<10; x++)
            {
                for(int y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    if(x || y)   // arr[i][j][0] may not be possible.
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(int k=1; k<n; k++)
    {
        cnt[s[k-1]-48][s[k]-48]++;
    }
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            ans=0;
            for(int x=0; x<10; x++)
            {
                for(int y=0; y<10; y++)
                {
                    if(arr[i][j][(y-x+10)%10]==INF && cnt[x][y])
                    {
                        ans=-1;
                        goto label;
                    }
                    ans+=cnt[x][y]*(arr[i][j][(y-x+10)%10]-1);
                }
            }
            label:
           cout<<ans<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 1000000000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll o=0;

int main()
{
    fast;
    string s;
    cin>>s;
    ll a[11][11],arr[10][10][10],tmp,n;
    for(ll i=0; i<10; i++)
        for(ll j=0; j<10; j++)
            for(ll x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            for(ll k=0; k<10; k++)
            {
                for(ll x=0; x<10; x++)
                {
                    for(ll y=0; y<10; y++)
                    {
                        tmp=(x*i+y*j)%10;
                        if(tmp==k && (x || y))
                        arr[i][j][k]=min(arr[i][j][k],x+y);
                    }
                }
            }
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ll x=0,ans=0;
            bool aa=1;
            for(ll k=1; k<n; k++)
            {
                x=((ll)(s[k]-s[k-1]+10ll))%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else
                {
                    ans+=arr[i][j][x]-1;
                }
            }
            if(aa)
            {
                a[i][j]=ans;
            }
            else a[i][j]=-1;
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 19
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    fast;
    string s;
    cin>>s;
    int a[11][11],arr[10][10][10],tmp,n;
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            for(int x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            for(int x=0; x<10; x++)
            {
                for(int y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    if(x || y)   // arr[i][j][0] might not be possible.
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            int x=0,ans=0;
            bool aa=1;
            for(int k=1; k<n; k++)
            {
                x=((int)(s[k]-s[k-1]+10))%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else
                {
                    ans+=arr[i][j][x]-1;
                }
            }
            if(aa)
            {
                a[i][j]=ans;
            }
            else a[i][j]=-1;
        }
    }
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 19
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int cnt[10][10];
int main()
{
    fast;
    string s;
    cin>>s;
    int a[11][11],arr[10][10][10],tmp,n,ans;
    for(int i=0; i<10; i++)
        for(int j=0; j<10; j++)
            for(int x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            for(int x=0; x<10; x++)
            {
                for(int y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    if(x || y)   // arr[i][j][0] may not be possible.
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(int k=1; k<n; k++)
    {
        cnt[s[k-1]-48][s[k]-48]++;
    }
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            ans=0;
            for(int x=0; x<10; x++)
            {
                for(int y=0; y<10; y++)
                {
                    if(arr[i][j][(y-x+10)%10]==INF)
                    {
                        ans=-1;
                        goto label;
                    }
                    ans+=cnt[x][y]*(arr[i][j][(y-x+10)%10]-1);
                }
            }
            label:
            a[i][j]=ans;
        }
    }
    for(int i=0; i<10; i++)
    {
        for(int j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 1000000000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll o=0;

int main()
{
    fast;
    string s;
    cin>>s;
    ll a[11][11],arr[10][10][10],tmp,n;
    for(ll i=0; i<10; i++)
        for(ll j=0; j<10; j++)
            for(ll x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            for(ll x=0; x<10; x++)
            {
                for(ll y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ll x=0,ans=0;
            bool aa=1;
            for(ll k=1; k<n; k++)
            {
                x=((ll)(s[k]-s[k-1]+10))%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else
                {
                    ans+=arr[i][j][x]-1;
                }
            }
            if(aa)
            {
                a[i][j]=ans;
            }
            else a[i][j]=-1;
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 1000000000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll o=0;

int main()
{
    fast;
    string s;
    cin>>s;
    ll a[11][11],arr[10][10][10],tmp,n;
    for(ll i=0; i<10; i++)
        for(ll j=0; j<10; j++)
            for(ll x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            for(ll x=0; x<10; x++)
            {
                for(ll y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(ll k=0; k<n; k++) if(k<n-1 && s[k]!=s[k+1]) o++;
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ll x=0,l=0,ans=0;
            bool aa=1;
            for(ll k=1; k<n; k++)
            {
                x=((ll)(s[k]-48)-l+10)%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else ans+=arr[i][j][x];
                l=s[k]-48;

            }
            if(aa)
            {
                a[i][j]=ans;
            }
            else a[i][j]=-1;

        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            if(a[i][j]!=-1)
            {
                cout<<a[i][j]-o<<" ";
            }
            else cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 1000000000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    fast;
    string s;
    cin>>s;
    ll a[11][11],arr[10][10][10],tmp,n;
    for(ll i=0; i<10; i++)
        for(ll j=0; j<10; j++)
            for(ll x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            for(ll x=0; x<10; x++)
            {
                for(ll y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    if(x || y)
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ll x=0,ans=0;
            bool aa=1;
            for(ll k=1; k<n; k++)
            {
                x=((ll)(s[k]-s[k-1]+10ll))%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else
                {
                    ans+=arr[i][j][x]-1;
                }
            }
            if(aa)
            {
                a[i][j]=ans;
            }
            else a[i][j]=-1;
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define INF 1000000000000001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{
    fast;
    string s;
    cin>>s;
    ll a[11][11],arr[10][10][10],tmp,n;
    for(ll i=0; i<10; i++)
        for(ll j=0; j<10; j++)
            for(ll x=0; x<10; x++) arr[i][j][x]=INF;
    n=s.size();
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            for(ll x=0; x<10; x++)
            {
                for(ll y=0; y<10; y++)
                {
                    tmp=(x*i+y*j)%10;
                    arr[i][j][tmp]=min(arr[i][j][tmp],x+y);
                }
            }
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            ll x=0,l=0,ans=0;
            bool aa=1;
            for(ll k=1; k<n; k++)
            {
                x=((ll)(s[k]-48)-l+10)%10;
                if(arr[i][j][x]==INF)
                {
                    aa=0;
                    break;
                }
                else ans+=arr[i][j][x];
                l=s[k]-48;
            }
            if(aa)
            {
                a[i][j]=ans-3;
            }
            else a[i][j]=-1;
        }
    }
    for(ll i=0; i<10; i++)
    {
        for(ll j=0; j<10; j++)
        {
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1000;
    visit[from]=0;
    queue<int> op;
    op.push(from);
    while(!op.empty())
    {
        int f=op.front();
        op.pop();
        if(f==to)
            return visit[f];
        int fir=(f+a)%10;
        int sic=(f+b)%10;
        if(visit[f]+1<=visit[fir])
        {
            visit[fir]=visit[f]+1;
            op.push(fir);
        }
        if(visit[f]+1<=visit[sic])
        {
            visit[sic]=visit[f]+1;
            op.push(sic);
        }
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {
                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(ans[s[i]-'0'][s[i+1]-'0'][j][k]==0);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1e9;
    visit[from]=0;
    queue<intt> op;
    op.push(from);
    while(!op.empty())
    {
        int f=op.front();
        op.pop();
        if(f==to)
            return visit[f];
        int fir=(f+a)%10;
        int sic=(f+b)%10;
        if(visit[f]+1<=visit[fir])
        {
            visit[fir]=visit[f]+1;
            op.push(fir);
        }
        if(visit[f]+1<=visit[sic])
        {
            visit[sic]=visit[f]+1;
            op.push(sic);
        }
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {
                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(s[i]==s[i+1]);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1e9;
    visit[from]=0;
    queue<intt> op;
    op.push(from);
    while(!op.empty())
    {
        int f=op.front();
        op.pop();
        if(f==to)
            return visit[f];
        int fir=(f+a)%10;
        int sic=(f+b)%10;
        if(visit[f]+1<=visit[fir])
        {
            visit[fir]=visit[f]+1;
            op.push(fir);
        }
        if(visit[f]+1<=visit[sic])
        {
            visit[sic]=visit[f]+1;
            op.push(sic);
        }
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {
                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(ans[s[i]-'0'][s[i+1]-'0'][j][k]==0);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1e9;
    visit[from]=0;
    queue<intt> op;
    op.push(from);
    while(!op.empty())
    {
        int f=op.front();
        op.pop();
        if(f==to)
            return visit[f];
        int fir=(f+a)%10;
        int sic=(f+b)%10;
        if(visit[f]+1<visit[fir])
        {
            visit[fir]=visit[f]+1;
            op.push(fir);
        }
        if(visit[f]+1<visit[sic])
        {
            visit[sic]=visit[f]+1;
            op.push(sic);
        }
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {
                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(s[i]==s[i+1]);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1000;
    visit[from]=1e9;
priority_queue< ii,vector<ii> ,greater<ii> > op;
    op.push({0,from});
    while(!op.empty())
    {
        ii f=op.top();
        op.pop();
        if(f.sc==to&&visit[to]!=1e9)
            return visit[f.sc];
        int fir=(f.sc+a)%10;
        int sic=(f.sc+b)%10;
        if(f.fr+1<=visit[fir])
        {
            visit[fir]=f.fr+1;
            op.push({visit[fir],fir});
        }
        if(f.fr+1<=visit[sic])
        {
            visit[sic]=f.fr+1;
            op.push({visit[sic],sic});
        }
    }
    return -1;
}
void mem()
{
    int i,j,k,c;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    mem();

    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {

                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(ans[s[i]-'0'][s[i+1]-'0'][j][k]==0);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;
string s;
int ans[10][10][10][10];
int an[10][10];
int  chek_one(int from,int to,int a,int b)
{
    int visit[10];
    int i;
    for(i=0; i<10; i++)
        visit[i]=1000;
    visit[from]=0;
priority_queue< ii,vector<ii> ,greater<ii> > op;
    op.push({0,from});
    while(!op.empty())
    {
        ii f=op.top();
        op.pop();
        if(f.sc==to)
            return visit[f.sc];
        int fir=(f.sc+a)%10;
        int sic=(f.sc+b)%10;
        if(visit[f.sc]+1<=visit[fir])
        {
            visit[fir]=visit[f.sc]+1;
            op.push({visit[fir],fir});
        }
        if(visit[f.sc]+1<=visit[sic])
        {
            visit[sic]=visit[f.sc]+1;
            op.push({visit[sic],sic});
        }
    }
    return -1;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i;
    int j;
    int k;
    int c;
    int g=s.length()-1;
    for(i=0; i<=9; i++)
    {
        for(j=0; j<=9; j++)
        {
            for(k=0; k<=9; k++)
            {
                for(c=0; c<=9; c++)
                {
                    ans[i][j][k][c]=chek_one(i,j,k,c);
                }
            }
        }
    }
    for(j=0; j<=9; j++)
    {
        for(k=0; k<=9; k++)
        {

            int ane=0;
            for(i=0; i<s.length()-1; i++)
            {
                if(s[i]==s[i+1])
                 continue;
                if(ans[s[i]-'0'][s[i+1]-'0'][j][k]==-1)
                {
                    ane=-1;
                    break;
                }
                else
                {

                    ane+=ans[s[i]-'0'][s[i+1]-'0'][j][k]-1+(ans[s[i]-'0'][s[i+1]-'0'][j][k]==0);
                }
            }
                if(ane==-1)
                    cout<<ane<<" ";
                else
                   cout<<ane<<" ";

        }
         cout<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int shortest(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int bfs(int i, int j, int src, int tar) {
    //cout << i << " " << j << " ULAZ " << src << " " << tar << endl;
    queue<Node> q;
    int visitedDigits[10] = {0};

    q.push({src, 0});
    visitedDigits[src] = 1;

    while (!q.empty()) {
        Node curr = q.front();
        q.pop();
        //cout << curr.val << "  NODE " << curr.dist << endl;
//        if (curr.dist > 50) {
//            return -1;
//        }

        if (curr.val == tar) {
            return curr.dist;
        }

        int i_d = (i + curr.val) % 10;
        int j_d = (j + curr.val) % 10;

//        if (i_d - curr.val != 0) {
//            q.push({i_d, curr.dist + 1});
//        }
//
//        if (j_d - curr.val != 0) {
//            q.push({j_d, curr.dist + 1});
//        }

        if(!visitedDigits[i_d]) {
            q.push({i_d, curr.dist + 1});
            visitedDigits[i_d] = 1;
        }
        if(!visitedDigits[j_d]) {
            q.push({j_d, curr.dist + 1});
            visitedDigits[j_d] = 1;
        }

    }

    return -1;
}

int table[10][10][10][10];

int minimumMissing(int i, int j, string &a) {
    int r = 0;
    for (int k = 1; k < a.size(); k++) {

//                    int res = shortest(i, j, get_int(a[k]), get_int(a[k + 1]));
        int res = table[(int)a[k-1] - 48][(int)a[k] - 48][i][j];
        if (res == -1) {
//                        cout << "greska: " << get_int(a[k]) << " " << get_int(a[k + 1]) << endl;
            r = -1;
            break;
        }
        r += (res-1);
    }
    return r;
}

int main() {

    string a;
    cin >> a;

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int x = 0; x < 10; x++) {
                for(int y = x; y < 10; y++) {
                    int r = shortest(x, y, i, j);
                    table[i][j][x][y] = r;
                    table[i][j][y][x] = r;
                }
            }
        }
    }

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            int r = minimumMissing(i, j, a);
            rr[i][j] = r;
            rr[j][i] = r;
        }
    }

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cout << rr[i][j] << " ";
        }
        cout << endl;
    }

//    for(int i = 0; i < 10; i++) {
//        for(int j = 0; j < 10; j++) {
//            for(int x = 0; x < 10; x++) {
//                for(int y = 0; y < 10; y++) {
//                    int r1 = shortest(x, y, i, j);
//                    int r2 = bfs(x, y, i, j);
//
//                    cout << r1 << " " << r2;
//                    if(r1 != r2) cout << "GRESKA";
//
//                    cout << endl;
//                }
//            }
//        }
//    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int bfs(int i, int j, int src, int tar) {
    //cout << i << " " << j << " ULAZ " << src << " " << tar << endl;
    queue<Node> q;
    q.push({src, 0});
    int s = 0;
    while (!q.empty()) {
        Node curr = q.front();
        //cout << curr.val << "  NODE " << curr.dist << endl;
        if (curr.dist > 50) {
            return -1;
        }

        if (curr.val % 10 == tar) {
            return curr.dist - 1;
        }

        int i_d = i + curr.val;
        int j_d = j + curr.val;

        if (i_d - curr.val != 0) {
            q.push({i_d, curr.dist + 1});
        }

        if (j_d - curr.val != 0) {
            q.push({j_d, curr.dist + 1});
        }

        q.pop();
    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (rr[i][j] != -2) {
                cout << rr[i][j] << " ";
            } else {
                int r = 0;
                for (int k = 0; k < a.size() - 1; k++) {
                    int res = bfs(i, j, get_int(a[k]), get_int(a[k + 1]));
                    if (res == -1) {
                        r = -1;
                        break;
                    }
                    r += res;
                }
                rr[i][j] = r;
                rr[j][i] = r;
                if (i == 0) {
                    rr[j][j] = r;
                }
                cout << r << " ";
            }
        }
        cout << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int shortest(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int bfs(int i, int j, int src, int tar) {
    //cout << i << " " << j << " ULAZ " << src << " " << tar << endl;
    queue<Node> q;
    int visitedDigits[10] = {0};

    q.push({src, 0});
    visitedDigits[src] = 1;

    while (!q.empty()) {
        Node curr = q.front();
        q.pop();
        //cout << curr.val << "  NODE " << curr.dist << endl;
//        if (curr.dist > 50) {
//            return -1;
//        }

        if (curr.val == tar) {
            return curr.dist;
        }

        int i_d = (i + curr.val) % 10;
        int j_d = (j + curr.val) % 10;

//        if (i_d - curr.val != 0) {
//            q.push({i_d, curr.dist + 1});
//        }
//
//        if (j_d - curr.val != 0) {
//            q.push({j_d, curr.dist + 1});
//        }

        if(!visitedDigits[i_d]) {
            q.push({i_d, curr.dist + 1});
            visitedDigits[i_d] = 1;
        }
        if(!visitedDigits[j_d]) {
            q.push({j_d, curr.dist + 1});
            visitedDigits[j_d] = 1;
        }

    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (rr[i][j] != -2) {
                cout << rr[i][j] << " ";
            } else {
                int r = 0;
                for (int k = 0; k < a.size() - 1; k++) {
                    int res = bfs(i, j, get_int(a[k]), get_int(a[k + 1]));
                    if (res == -1) {
//                        cout << "greska: " << get_int(a[k]) << " " << get_int(a[k + 1]) << endl;
                        r = -1;
                        break;
                    }
                    r += (res-1);
                }
                rr[i][j] = r;
                rr[j][i] = r;
//                if (i == 0) {
//                    rr[j][j] = r;
//                }
                cout << r << " ";
            }
        }
        cout << endl;
    }

//    for(int i = 0; i < 10; i++) {
//        for(int j = 0; j < 10; j++) {
//            for(int x = 0; x < 10; x++) {
//                for(int y = 0; y < 10; y++) {
//                    int r1 = shortest(x, y, i, j);
//                    int r2 = bfs(x, y, i, j);
//
//                    cout << r1 << " " << r2;
//                    if(r1 != r2) cout << "GRESKA";
//
//                    cout << endl;
//                }
//            }
//        }
//    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int bfs(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    int table[10][10][10][10];

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int x = 0; x < 10; x++) {
                for(int y = x; y < 10; y++) {
                    table[i][j][x][y] = -2;
                }
            }
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (rr[i][j] != -2) {
                cout << rr[i][j] << " ";
            } else {
                int r = 0;
                for (int k = 0; k < a.size() - 1; k++) {
                    int res;

                    if(table[(int)a[k] - 48][(int)a[k+1] - 48][i][j] != -2) {
                        res = table[(int)a[k] - 48][(int)a[k+1] - 48][i][j];
                    }
                    else {
                        res = bfs(i, j, get_int(a[k]), get_int(a[k+1]));
                        table[(int)a[k] - 48][(int)a[k+1] - 48][i][j] = res;
                    }

                    if (res == -1) {
                        r = -1;
                        break;
                    }
                    r += (res);
                }
                rr[i][j] = r;
                rr[j][i] = r;
//                if (i == 0) {
//                    rr[j][j] = r;
//                }
                cout << r << " ";
            }
        }
        cout << endl;
    }

//    cout << bfs(3, 2, 4, 8) << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int shortest(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int bfs(int i, int j, int src, int tar) {
    //cout << i << " " << j << " ULAZ " << src << " " << tar << endl;
    queue<Node> q;
    int visitedDigits[10] = {0};

    q.push({src, 0});
    visitedDigits[src] = 1;

    while (!q.empty()) {
        Node curr = q.front();
        q.pop();
        //cout << curr.val << "  NODE " << curr.dist << endl;
//        if (curr.dist > 50) {
//            return -1;
//        }

        if (curr.val == tar) {
            return curr.dist;
        }

        int i_d = (i + curr.val) % 10;
        int j_d = (j + curr.val) % 10;

//        if (i_d - curr.val != 0) {
//            q.push({i_d, curr.dist + 1});
//        }
//
//        if (j_d - curr.val != 0) {
//            q.push({j_d, curr.dist + 1});
//        }

        if(!visitedDigits[i_d]) {
            q.push({i_d, curr.dist + 1});
            visitedDigits[i_d] = 1;
        }
        if(!visitedDigits[j_d]) {
            q.push({j_d, curr.dist + 1});
            visitedDigits[j_d] = 1;
        }

    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int table[10][10][10][10];
    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int x = 0; x < 10; x++) {
                for(int y = x; y < 10; y++) {
                    int r = shortest(x, y, i, j);
                    table[i][j][x][y] = r;
                    table[i][j][y][x] = r;
                }
            }
        }
    }

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            int r = 0;
            for (int k = 1; k < a.size(); k++) {

//                    int res = shortest(i, j, get_int(a[k]), get_int(a[k + 1]));
                int res = table[get_int(a[k-1])][get_int(a[k])][i][j];
                if (res == -1) {
//                        cout << "greska: " << get_int(a[k]) << " " << get_int(a[k + 1]) << endl;
                    r = -1;
                    break;
                }
                r += (res-1);
            }
            rr[i][j] = r;
            rr[j][i] = r;
//                if (i == 0) {
//                    rr[j][j] = r;
//                }
//                cout << r << " ";

        }
//        cout << endl;
    }

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cout << rr[i][j] << " ";
        }
        cout << endl;
    }

//    for(int i = 0; i < 10; i++) {
//        for(int j = 0; j < 10; j++) {
//            for(int x = 0; x < 10; x++) {
//                for(int y = 0; y < 10; y++) {
//                    int r1 = shortest(x, y, i, j);
//                    int r2 = bfs(x, y, i, j);
//
//                    cout << r1 << " " << r2;
//                    if(r1 != r2) cout << "GRESKA";
//
//                    cout << endl;
//                }
//            }
//        }
//    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int bfs(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    int table[10][10][10][10];

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int x = 0; x < 10; x++) {
                for(int y = x; y < 10; y++) {
                    table[i][j][x][y] = -2;
                }
            }
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (rr[i][j] != -2) {
                cout << rr[i][j] << " ";
            } else {
                int r = 0;
                for (int k = 0; k < a.size() - 1; k++) {
                    int res;

                    if(table[(int)a[k] - 48][(int)a[k+1] - 48][i][j] != -2) {
                        res = table[(int)a[k] - 48][(int)a[k+1] - 48][i][j];
                    }
                    else {
                        res = bfs(i, j, (int)a[k] - 48, (int)a[k+1] - 48);
                        table[(int)a[k] - 48][(int)a[k+1] - 48][i][j] = res;
                    }

                    if (res == -1) {
                        r = -1;
                        break;
                    }
                    r += (res);
                }
                rr[i][j] = r;
                rr[j][i] = r;
//                if (i == 0) {
//                    rr[j][j] = r;
//                }
                cout << r << " ";
            }
        }
        cout << endl;
    }

//    cout << bfs(3, 2, 4, 8) << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int shortest(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int bfs(int i, int j, int src, int tar) {
    //cout << i << " " << j << " ULAZ " << src << " " << tar << endl;
    queue<Node> q;
    int visitedDigits[10] = {0};

    q.push({src, 0});
//    visitedDigits[src] = 1;

    while (!q.empty()) {
        Node curr = q.front();
        q.pop();
        //cout << curr.val << "  NODE " << curr.dist << endl;
//        if (curr.dist > 50) {
//            return -1;
//        }

        if (curr.val == tar) {
            return curr.dist;
        }

        int i_d = (i + curr.val) % 10;
        int j_d = (j + curr.val) % 10;

//        if (i_d - curr.val != 0) {
//            q.push({i_d, curr.dist + 1});
//        }
//
//        if (j_d - curr.val != 0) {
//            q.push({j_d, curr.dist + 1});
//        }

        if(!visitedDigits[i_d]) {
            q.push({i_d, curr.dist + 1});
            visitedDigits[i_d] = 1;
        }
        if(!visitedDigits[j_d]) {
            q.push({j_d, curr.dist + 1});
            visitedDigits[j_d] = 1;
        }

    }

    return -1;
}

int table[10][10][10][10];

int minimumMissing(int i, int j, string &a) {
    int r = 0;
    for (int k = 1; k < a.size(); k++) {

//                    int res = shortest(i, j, get_int(a[k]), get_int(a[k + 1]));
        int res = table[(int)a[k-1] - 48][(int)a[k] - 48][i][j];
        if (res == -1) {
//                        cout << "greska: " << get_int(a[k]) << " " << get_int(a[k + 1]) << endl;
            r = -1;
            break;
        }
        r += (res);
    }
    return r;
}

int main() {

    string a;
    cin >> a;

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            for(int x = 0; x < 10; x++) {
                for(int y = x; y < 10; y++) {
                    int r = bfs(x, y, i, j);
                    table[i][j][x][y] = r;
                    table[i][j][y][x] = r;
                }
            }
        }
    }

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = i; j < 10; j++) {
            int r = minimumMissing(i, j, a);
            rr[i][j] = r;
            rr[j][i] = r;
        }
    }

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cout << rr[i][j] << " ";
        }
        cout << endl;
    }

//    for(int i = 0; i < 10; i++) {
//        for(int j = 0; j < 10; j++) {
//            for(int x = 0; x < 10; x++) {
//                for(int y = 0; y < 10; y++) {
//                    int r1 = shortest(x, y, i, j);
//                    int r2 = bfs(x, y, i, j);
//
//                    cout << r1 << " " << r2;
//                    if(r1 != r2) cout << "GRESKA";
//
//                    cout << endl;
//                }
//            }
//        }
//    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct Node {
    int val, dist;
};

int get_int(char c) {
    string s(1, c);
    return stoi(s);
}

int bfs(int i, int j, int s, int e) {
    queue<int> q;
    unordered_map<int, int> dist;

    q.push(s);
    dist[s] = 0;

    int result = 0;
    while(!q.empty()) {
        int n = q.front();
        q.pop();
        int d = dist[n];

        int next = (n + i) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }

        next = (n + j) % 10;
        if(next == e)
            return d + 1;
        if(dist.find(next) == dist.end()) {
            q.push(next);
            dist[next] =  d + 1;
        }
    }

    return -1;
}

int main() {

    string a;
    cin >> a;

    int rr[10][10];

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            rr[i][j] = -2;
        }
    }

    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (rr[i][j] != -2) {
                cout << rr[i][j] << " ";
            } else {
                int r = 0;
                for (int k = 0; k < a.size() - 1; k++) {
                    int res = bfs(i, j, (int)a[k] - 48, (int)a[k+1] - 48);
                    if (res == -1) {
                        r = -1;
                        break;
                    }
                    r += (res-1);
                }
                rr[i][j] = r;
                rr[j][i] = r;
                if (i == 0) {
                    rr[j][j] = r;
                }
                cout << r << " ";
            }
        }
        cout << endl;
    }

    return 0;
}