//高精度,用int存储会爆掉,应该用vector数组来存储。再一位一位作运算,无论加减乘除都是类似的计算思路,将数组反过来一位一位计算。
#include<cstring>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
vector<int> add(vector<int>&A,vector<int>&B)
{
vector<int>C;
int t=0;
for(int i=0;i<A.size()||i<B.size();i++)
{
t+=A[i];
t+=B[i];
C.push_back(t%10);
t/=10;
}
if(t)C.push_back(1);
return C;
}
vector<int> pop(vector<int>&A,vector<int>&B)
{
vector<int>C;
int t=0;
for(int i=0;i<A.size();i++)
{
t=A[i]-t;
t-=B[i];
C.push_back((t+10)%10);
if(t<0)t=1;
else t=0;
}
//除去尾零
while(C.size()>1&&C.back()==1)C.pop_back();
return C;
}
vector<int> mul(vector<int> &A,int b)
{
vector<int>C;
int t=0;
for(int i=0;i<A.size()||t;i++)//注意t!=0时还要运行一次
{
t+=A[i]*b;
C.push_back(t%10);
t/=10;
}
while(C.size()>1&&C.back()==1)C.pop_back();
return C;
}
vector<int> div(vector<int> &A,int b,int &t)
{
vector<int>C;
t=0;
for(int i=A.size()-1;i>=0;i--)
{
t=t*10+A[i];
C.push_back(t/b);
t%=b;
}
reverse(C.begin(),C.end());
while(C.size()>1&&C.back()==0)C.pop_back();
return C;
}
//A >= B, A >= 0, B >= 0
int main()
{
int r=0;
string x;
cin>>x;
string a,b;
cin>>a>>b;
vector<int>A,B,C;
//将字符串反过来
for(int i=a.size()-1;i>=0;i--)A.push_back(a[i]-'0');
for(int i=b.size()-1;i>=0;i--)B.push_back(b[i]-'0');
if(x=="add")C=add(A,B);
else if(x=="pop")C=pop(A,B);
else if(x=="mul")C=mul(A,std::stoi(b));
else if(x=="div")C=div(A,std::stoi(b),r);
else cout<<"error";
//再反过来输出
for(int i=C.size()-1;i>=0;i--)printf("%d",C[i]);
puts(" ");
if(x=="div")cout<<r;
}