#include<bits/stdc++.h>
using namespace std;
//#define int long long 
const int N=1e5+5;
const int mod=10007;
int a=0,b=1;
int c;
int main()
{
    while(scanf("(x%d)",&c))
    {
        a=((a*c+b)%mod+mod)%mod;
        b=(b*c%mod+mod)%mod;
    }
   cout<<a<<endl;
   return 0;
}