#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef pair PI; #define REP(i,n) for (int i=0; i=0; i--) #define FOREACH(it,a) for (__typeof(a.begin()) it=a.begin(); it!=a.end(); it++) #define ll long long string kladne(int base,ll x) { // cout<=0) mod = x%base; else { mod = (base-(-x)%base)%base; mod = (mod+4*base)%base; } return kladne(base, -(x-mod)/base)+char('0'+mod); } ll from(ll base,ll nasob,ll x) { if (x==0) return 0; return (x%10)*nasob+from(base,-nasob*base,x/10); } int main() { char oper[15]; string op; int base; ll cis; while (scanf("%[^-\n]-%d %lld\n",oper,&base,&cis)==3) { // cout<<": "<