#include using namespace std; using ll = long long; using P = pair; templatestruct Kitamasa{ vectorb,c; int k; Kitamasa(vectorb,vectorc,int k):b(b),c(c),k(k){}; void add(T &a,const T &b){ a+=b; a%=10; } T prod(const T &a,const T &b){ return (a*b)%10; } vector next_v(const vector&v){ vector ret(k); for(int i=0; i double_v(const vector&v){ vector ret(k); vector a(k,vector(k)); a[0] = v; for(int j=1; j(k); for(int i=0; i v{n}; while(m>k){ if(m%2||m/2<=k) m--; else m/=2; v.push_back(m); } reverse(v.begin(),v.end()); vector dp(2,vector(k,0)); int cur = 1,pre = 0; dp[pre] = c; m = v.size(); for(int l=1; l b(3); ll k; for(auto &i:b){ cin>>i; i %= 10; } cin>>k; vector c(3,1); Kitamasa kita(b,c,3); cout<