#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <deque>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
class Bigint {
public:
Bigint():negative(false) {}
Bigint(const ll);
Bigint(const char*);
Bigint(const string);
Bigint(const Bigint &);
Bigint & operator = (const Bigint &);
friend istream & operator >> (istream &, Bigint &);
friend ostream & operator << (ostream &, const Bigint &);
Bigint operator + (const Bigint &) const;
Bigint operator - (const Bigint &) const;
Bigint operator * (const Bigint &) const;
Bigint operator / (const ll &) const;
Bigint operator / (const Bigint &) const;
ll operator % (const ll &) const;
Bigint operator % (const Bigint &) const;
bool operator > (const Bigint &) const;
bool operator == (const Bigint &) const;
bool operator >= (const Bigint &) const;
friend Bigint abs(const Bigint &);
Bigint operator - () const;
private:
deque<int> num;
bool negative;
};
Bigint::Bigint(const ll x) {
ll t = abs(x);
negative = x >= 0 ? false : true;
while (t > 0) {
num.push_back(t % 10);
t /= 10;
}
reverse(num.begin(), num.end());
}
Bigint::Bigint(const char* str) {
unsigned i = str[0] == '-' ? 1 : 0;
this->negative = str[0] == '-' ? true : false;
for (; i < strlen(str); ++i) num.push_back(str[i] - '0');
}
Bigint::Bigint(const string str) {
unsigned i = str[0] == '-' ? 1 : 0;
this->negative = str[0] == '-' ? true : false;
for (; i < str.size(); ++i) num.push_back(str[i] - '0');
}
Bigint::Bigint(const Bigint &x) {
negative = x.negative;
num = x.num;
}
Bigint & Bigint::operator = (const Bigint &x) {
negative = x.negative;
num = x.num;
return *this;
}
istream & operator >> (istream &is, Bigint & x) {
string str;
is >> str;
x = str;
return is;
}
ostream & operator << (ostream &os, const Bigint &x) {
if (x.negative) os << '-';
for (unsigned i = 0; i < x.num.size(); ++i)
os << x.num[i];
return os;
}
bool Bigint::operator > (const Bigint & rhs) const {
Bigint x = (*this), y = rhs;
if (!x.negative && y.negative) return true;
if (x.negative && !y.negative) return false;
if (x.negative && y.negative) swap(x, y);
if (x.num.size() > y.num.size()) return true;
if (x.num.size() < y.num.size()) return false;
for (unsigned i = 0; i < x.num.size(); ++i) {
if (x.num[i] > y.num[i]) return true;
if (x.num[i] < y.num[i]) return false;
}
return false;
}
bool Bigint::operator == (const Bigint & rhs) const {
return negative == rhs.negative && num == rhs.num;
}
bool Bigint::operator >= (const Bigint & rhs) const {
return *this > rhs || *this == rhs;
}
Bigint abs(const Bigint & rhs) {
Bigint res;
res.negative = false;
res.num = rhs.num;
return res;
}
Bigint Bigint::operator - () const {
Bigint ret = *this;
ret.negative = !ret.negative;
return ret;
}
Bigint Bigint::operator + (const Bigint & y) const {
if (!this->negative && y.negative) return *this - abs(y);
if (this->negative && !y.negative) return y - abs(*this);
if (this->negative && y.negative) return -(abs(*this) + abs(y));
Bigint x = *this, res;
int temp = 0;
for (int i = x.num.size() - 1, j = y.num.size() - 1; i >= 0 || j >= 0; --i, --j) {
int a = i < 0 ? 0 : x.num[i];
int b = j < 0 ? 0 : y.num[j];
res.num.push_front((a + b + temp) % 10);
temp = (a + b + temp) / 10;
}
if (temp != 0) res.num.push_front(temp);
return res;
}
Bigint Bigint::operator * (const Bigint & y) const {
deque<int> a, b, res;
copy(this->num.begin(), this->num.end(), front_inserter(a));
copy(y.num.begin(), y.num.end(), front_inserter(b));
res.resize(a.size() + b.size() + 5);//
for (unsigned i = 0; i < a.size(); ++i) for (unsigned j = 0; j < b.size(); ++j)
res[i + j] += a[i] * b[j];
for (unsigned i = 0; i < res.size() - 1; ++i) {
res[i + 1] += res[i] / 10;
res[i] %= 10;
}
while (res.size() >= 2 && res.back() == 0)
res.pop_back();
reverse(res.begin(), res.end());
Bigint ret;
ret.negative = this->negative ^ y.negative;
ret.num = res;
return ret;
}
Bigint Bigint::operator - (const Bigint & y) const {
if (!this->negative && y.negative) return *this + abs(y);
if (this->negative && !y.negative) return -(abs(*this) + y);
if (this->negative && y.negative) return abs(y) - abs(*this);
deque<int> a, b, res;
Bigint ret;
copy(this->num.begin(), this->num.end(), front_inserter(a));
copy(y.num.begin(), y.num.end(), front_inserter(b));
if (y > *this) swap(a, b), ret.negative = true;
res.resize(max(a.size(), b.size()) + 5);
for (unsigned i = 0, j = 0; i < a.size() || j < b.size(); ++i, ++j) {
int m = i < a.size() ? a[i] : 0;
int n = j < b.size() ? b[j] : 0;
res[i] = m - n;
}
for (unsigned i = 0; i < res.size() - 1; ++i) if (res[i] < 0) {
res[i] += 10;
--res[i + 1];
}
while (res.size() >= 2 && res.back() == 0)
res.pop_back();
reverse(res.begin(), res.end());
ret.num = res;
return ret;
}
Bigint Bigint::operator / (const ll & y) const {
ll temp = 0;
Bigint x = (*this), res;
for (unsigned i = 0; i < x.num.size(); ++i) {
temp = temp * 10 + x.num[i];
res.num.push_back((int)(temp / y));
temp %= y;
}
while (res.num.size() >= 2 && res.num.front() == 0)
res.num.pop_front();
return res;
}
Bigint Bigint::operator / (const Bigint & y) const {
Bigint x = (*this), lf = "0", rt = "0", res = "0", mid = "0";
if(x.num.size() < y.num.size()) return res = "0";
else if(x.num.size() == y.num.size()) lf = 1, rt = 9;
else {
for (unsigned i = 0; i < x.num.size() - y.num.size(); i++)
lf.num.push_back(x.num[i]), rt.num.push_back(x.num[i]);
rt.num.push_back(x.num[x.num.size() - y.num.size()]);
lf.num.pop_front(), rt.num.pop_front();
}
while(rt >= lf) {
mid = (lf + rt) / 2;
if(x >= mid*y) res = mid, lf = mid + 1;
else rt = mid - 1;
}
return res;
}
ll Bigint::operator % (const ll & y) const {
ll res = 0;
for (unsigned i = 0; i < this->num.size(); ++i)
res = (res * 10 + this->num[i]) % y;
return res;
}
Bigint Bigint::operator % (const Bigint & y) const {
Bigint res;
return res = *this - (*this/y*y);
}
int main() {
Bigint a, b;
cin >> a >> b;
cout << a+b << endl << a-b << endl << a*b << endl << a/b << endl << a%b;
// cout << a/b;
return 0;
}