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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007LL

typedef vector<ll> vec;
typedef vector<vec> mat;

mat operator*(const mat& a,const mat& b){
  mat res(4,vec(4,0));
  const ll modl=8*mod*mod;
  rep(i,4){
    rep(k,4){
      rep(j,4){
        res[i][j]+=a[i][k]*b[k][j];
        if(res[i][j]>=modl)res[i][j]-=modl;
      }
    }
    rep(j,4)res[i][j]%=mod;
  }
  return res;
}

mat mpow(mat a,ll n){
  mat res(4,vec(4,0));
  rep(i,4)res[i][i]=1;
  while(n>0){
    if(n&1)res=res*a;
    a=a*a;
    n>>=1;
  }
  return res;
}

ll pls[4][4]={
  {1, 0, 1, 0},
  {0, 0, 0, 1},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll mns[4][4]={
  {1, 0, 1, 0},
  {0, 0, 0, mod-1},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll mul[4][4]={
  {1, 0, 0, 0},
  {0, 0, 1, 0},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll num[4][4]={
  {1, 0, 0, 0},
  {0, 1, 0, 0},
  {0, 0, 10, 0},
  {0, 0, 0, 1},
};

int N;

int main(){
  scanf("%d",&N);
  vector<int> ps(N);
  vector<string> rs(N);
  rep(i,N){
    cin>>ps[i]>>rs[i];
  }
  ps.push_back(1); rs.push_back("+"); N++;
  mat crt(4,vec(4,0));
  rep(i,4)crt[i][i]=1;

  rep(i,N){
    mat m(4,vec(4,0));
    rep(j,4)m[j][j]=1;
    rep(j,rs[i].size()){
      mat op(4,vec(4,0));
      if(rs[i][j]=='+'){
        rep(k,4)rep(l,4)op[k][l]=pls[k][l];
      }
      if(rs[i][j]=='-'){
        rep(k,4)rep(l,4)op[k][l]=mns[k][l];
      }
      if(rs[i][j]=='*'){
        rep(k,4)rep(l,4)op[k][l]=mul[k][l];
      }
      if(isdigit(rs[i][j])){
        rep(k,4)rep(l,4)op[k][l]=num[k][l];
        op[2][1]=rs[i][j]-'0';
      }
      m=op*m;
    }
    m=mpow(m,ps[i]);
    crt=m*crt;
  }

  cout<<(crt[0][1]+crt[0][3])%mod<<endl;
  return 0;
}

