#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define int long long
#define float long double
#define push_back emplace_back
const int N = 1e6+5;
const float EPSILON = 1e-9;
struct re
{
    int x, y, a;
    bool operator < (const re &o) const
    {
        return x < o.x;
    }
};

vector<int> A, B;
int pointer;

bool bad(int l1, int l2, int l3)
{
    return (B[l3]-B[l1])*(A[l1]-A[l2]) - (B[l2]-B[l1])*(A[l1]-A[l3]) > EPSILON;
}

void add(int a, int b)
{
    A.push_back(a);
    B.push_back(b);
    while(A.size() >= 3 && bad(A.size()-3,A.size()-2,A.size()-1))
    {
        A.erase(A.end()-2);
        B.erase(B.end()-2);
    }
}

int query(int x)
{
    if (pointer >= A.size())
        pointer = A.size()-1;
    while(pointer < A.size()-1 && A[pointer]*x + B[pointer] < A[pointer+1]*x + B[pointer+1])
        pointer++;
    return A[pointer]*x+B[pointer];
}

int n, x, y, a;
long long dp[N];
re rect[N];

signed main()
{
    scanf("%lld",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld %lld %lld",&x,&y,&a);
        rect[i] = {x,y,a};
    }
    sort(rect,rect+n);
    //for (int i = 0; i < n; i++)
    //    cout << rect[i].x << ' ' << rect[i].y << ' ' << rect[i].a << endl;
    dp[0] = rect[0].x*rect[0].y - rect[0].a;
    add(-rect[0].x,dp[0]);
    for (int i = 1; i < n; i++)
    {
        dp[i] = query(rect[i].y) + rect[i].x*rect[i].y - rect[i].a;
        //cout << rect[i].y + rect[i].x*rect[i].y - rect[i].a << endl;
        //cout << dp[i] << endl;
        add(-rect[i].x,dp[i]);
    }
    int mx = 0;
    for (int i = 0; i < n; i++)
        mx = max(mx,dp[i]);
    printf("%lld",mx);
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];
int ptr;

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    ptr = min(ptr, sz(m) - 1);
    while (ptr < sz(m) - 1 && f(ptr, x) <= f(ptr + 1, x)) ptr++;
    return f(ptr, x);
}

int main() {
    optimize();
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p, p + n);
    ptr = 0;
    add(0, 0);
    for (int i = 0; i < n; ++i) {
        if (i != 0) assert(p[i].F.F > p[i - 1].F.F);
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp, dp + n)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vii opt;
ll dp[mxN];

ll Cost(int j, int i) { return (p[i].F.F - p[j].F.F) * p[i].F.S - p[i].S; }

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p + 1, p + n + 1);
    dp[0] = 0;
    opt.PB({0, 0});
    for (int x = 1; x <= n; ++x) {
        int k = (--lower_bound(all(opt), make_pair((x + 1), 0)))->second;
        dp[x] = dp[k] + Cost(k, x);
        cout << dp[x] << endl;
        for (int i = sz(opt) - 1; i >= 0; --i) {
            int y = opt[i].F, oldK = opt[i].S;
            if (y > x && dp[x] + Cost(x, y) > dp[oldK] + Cost(oldK, y)) opt.pop_back();
            else {
                int lo = y + 1, hi = n + 1;
                while (lo < hi) {
                    int mid = (lo + hi) / 2;
                    if (dp[x] + Cost(x, mid) >= dp[oldK] + Cost(oldK, mid)) hi = mid;
                    else lo = mid + 1;
                }
                if (hi != n + 1) opt.PB({hi, x});
                break;
            }
        }
        if (opt.empty()) opt.PB({0, x});
    }
    cout << *(max_element(dp, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pii, int> p[mxN];
vii opt;
ll dp[mxN];

ll Cost(int j, int i) { return (p[i].F.F - p[j].F.F) * p[i].F.S - p[i].S; }

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p, p + n);
    dp[0] = 0;
    opt.PB({0, 0});
    for (int x = 1; x <= n; ++x) {
        int k = (--lower_bound(all(opt), make_pair((x + 1), 0)))->second;
        dp[x] = dp[k] + Cost(k, x);
        for (int i = sz(opt) - 1; i >= 0; --i) {
            int y = opt[i].F, oldK = opt[i].S;
            if (y > x && dp[x] + Cost(x, y) > dp[oldK] + Cost(oldK, y)) opt.pop_back();
            else {
                int lo = y + 1, hi = n + 1;
                while (lo < hi) {
                    int mid = (lo + hi) / 2;
                    if (dp[x] + Cost(x, mid) >= dp[oldK] + Cost(oldK, mid)) hi = mid;
                    else lo = mid + 1;
                }
                if (hi != n + 1) opt.PB({hi, x});
                break;
            }
        }
        if (opt.empty()) opt.PB({0, x});
    }
    cout << *(max_element(dp, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];
int ptr;

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    ptr = min(ptr, sz(m) - 1);
    while (ptr < sz(m) - 1 && f(ptr, x) <= f(ptr + 1, x)) ptr++;
    return f(ptr, x);
}

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p + 1, p + n + 1);
    ptr = 0;
    add(0, 0);
    for (int i = 1; i <= n; ++i) {
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp + 1, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];
int ptr;

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    ptr = min(ptr, sz(m) - 1);
    while (ptr < sz(m) - 1 && f(ptr, x) <= f(ptr + 1, x)) ptr++;
    return f(ptr, x);
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p + 1, p + n + 1);
    ptr = 0;
    add(0, 0);
    for (int i = 1; i <= n; ++i) {
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp + 1, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    int lo = 0, hi = sz(m) - 1;
    while (hi - lo >= 10) {
        int mid1 = (lo + lo + hi) / 3;
        int mid2 = (lo + hi + hi) / 3;
        ll y1 = f(mid1, x), y2 = f(mid2, x);
        if (y1 <= y2) lo = mid1 + 1;
        else hi = mid2 - 1;
    }
    ll ans = 0LL;
    for (int i = lo; i <= hi; ++i) ans = max(ans, f(i, x));
    return ans;
}

int main() {
    optimize();
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p, p + n);
    add(0, 0);
    for (int i = 0; i < n; ++i) {
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp, dp + n)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];
int ptr;

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    ptr = min(ptr, sz(m) - 1);
    while (ptr < sz(m) - 1 && f(ptr, x) <= f(ptr + 1, x)) ptr++;
    return f(ptr, x);
}

int main() {
    optimize();
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p, p + n);
    ptr = 0;
    add(0, 0);
    for (int i = 0; i < n; ++i) {
        if (i != 0) assert(p[i].F.S < p[i - 1].F.S);
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp, dp + n)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vii opt;
ll dp[mxN];

ll Cost(int j, int i) { return (p[i].F.F - p[j].F.F) * p[i].F.S - p[i].S; }

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p + 1, p + n + 1);
    dp[0] = 0;
    opt.PB({0, 0});
    for (int x = 1; x <= n; ++x) {
        int k = (--lower_bound(all(opt), make_pair((x + 1), 0)))->second;
        dp[x] = dp[k] + Cost(k, x);
        for (int i = sz(opt) - 1; i >= 0; --i) {
            int y = opt[i].F, oldK = opt[i].S;
            if (y > x && dp[x] + Cost(x, y) > dp[oldK] + Cost(oldK, y)) opt.pop_back();
            else {
                int lo = y + 1, hi = n + 1;
                while (lo < hi) {
                    int mid = (lo + hi) / 2;
                    if (dp[x] + Cost(x, mid) >= dp[oldK] + Cost(oldK, mid)) hi = mid;
                    else lo = mid + 1;
                }
                if (hi != n + 1) opt.PB({hi, x});
                break;
            }
        }
        if (opt.empty()) opt.PB({0, x});
    }
    cout << *(max_element(dp, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vl m, c;
ll dp[mxN];

ll f(int i, ll x) { return m[i] * x + c[i]; }

bool isBad(int x1, int x2, int x3) {
    return double(c[x3] - c[x1]) * double(m[x1] - m[x2]) >= double(c[x2] - c[x1]) * double(m[x1] - m[x3]);
}

void add(int _m, int _c) {
    m.PB(_m);
    c.PB(_c);
    while (sz(m) >= 3 && isBad(sz(m) - 3, sz(m) - 2, sz(m) - 1)) {
        m.erase(m.end() - 2);
        c.erase(c.end() - 2);
    }
}

ll query(ll x) {
    int lo = 0, hi = sz(m) - 1;
    while (hi - lo >= 3) {
        int mid1 = (lo + lo + hi) / 3;
        int mid2 = (lo + hi + hi) / 3;
        ll y1 = f(mid1, x), y2 = f(mid2, x);
        if (y1 <= y2) lo = mid1 + 1;
        else hi = mid2 - 1;
    }
    ll ans = -infLL;
    for (int i = lo; i <= hi; ++i) ans = max(ans, f(i, x));
    return ans;
}

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p + 1, p + n + 1);
    add(0, 0);
    for (int i = 1; i <= n; ++i) {
        dp[i] = query(p[i].F.S) + p[i].F.F * p[i].F.S - p[i].S;
        add(-p[i].F.F, dp[i]);
    }
    cout << *(max_element(dp + 1, dp + n + 1)) << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(x) (int) x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000009

#define mem(a, b) memset(a, b, sizeof(a))
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed, ios::floatfield);
#define file() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

inline bool checkBit(ll n, int i) { return n & (1LL << i); }
inline ll setBit(ll n, int i) { return n | (1LL << i); }
inline ll resetBit(ll n, int i) { return n & (~(1LL << i)); }

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a * b) % MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); return (a + b) % MOD; }
inline ll modSub(ll a, ll b) { a %= MOD; b %= MOD; normal(a); normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1LL; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

const int mxN = 1e6 + 123;

int n;
pair<pll, ll> p[mxN];
vii opt;
ll dp[mxN];

ll Cost(int j, int i) { return (p[i].F.F - p[j].F.F) * p[i].F.S - p[i].S; }

int main() {
    optimize();
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> p[i].F.F >> p[i].F.S >> p[i].S;
    sort(p, p + n);
    dp[0] = 0;
    opt.PB({0, 0});
    for (int x = 1; x <= n; ++x) {
        int k = (--lower_bound(all(opt), make_pair((x + 1), 0)))->second;
        dp[x] = dp[k] + Cost(k, x);
        for (int i = sz(opt) - 1; i >= 0; --i) {
            int y = opt[i].F, oldK = opt[i].S;
            if (y > x && dp[x] + Cost(x, y) > dp[oldK] + Cost(oldK, y)) opt.pop_back();
            else {
                int lo = y + 1, hi = n + 1;
                while (lo < hi) {
                    int mid = (lo + hi) / 2;
                    if (dp[x] + Cost(x, mid) >= dp[oldK] + Cost(oldK, mid)) hi = mid;
                    else lo = mid + 1;
                }
                if (hi != n + 1) opt.PB({hi, x});
                break;
            }
        }
        if (opt.empty()) opt.PB({0, x});
    }
    cout << *(max_element(dp, dp + n + 1)) << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

// long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 2e6+50;
// mt19937 rng1(chrono::steady_clock::now().time_since_epoch().count());

template<class T = pair<long long, long long>>
class LCT{
public:
    int n, n_nodes;
    T tree[MAXN];
    long long p[MAXN]; // position of all possible evaluation points
    int lid[MAXN];
    // Right node's index is always 1 + left node's index
    // lid[i] = 0 means no left node generated.

    long long l0 = -1e9, r0 = 1e9, INF = -(1LL<<60);
    inline long long eval(const T & line, long long x) { return line.first * x + line.second; }
    inline long long eval(const T & line1, const T & line2, long long x) {
        return (line2.first - line2.first) * x + line1.second - line2.second;
    }
    inline bool better(long long x, long long y) { return x > y; }
    inline long long op(long long x, long long y) { return max(x, y); }

    template<class Iterator>
    void init(Iterator begin, Iterator end) {
        n = end - begin; // std::distance(begin, end);
        for(int i = 0; i < n; i++) p[i] = *(begin + i);
        sort(p, p + n);
        n = unique(p, p + n) - p;

        n_nodes = 1;
        tree[0] = {0, INF};

        memset(lid, 0, sizeof(lid));
    }

    void create_child(int node) {
        if(!lid[node]) {
            lid[node] = n_nodes;
            tree[n_nodes++] = {0, INF};
            tree[n_nodes++] = {0, INF};
        }
    }

    void _add(T & line, int node, int l, int r) {
        // print("add", line, node, l, r);
        int m = l + (r - l) / 2;
        int ll=p[l],rr=p[r],mm=p[m];

        bool l_res = better(eval(line, tree[node], ll), 0);
        bool m_res = better(eval(line, tree[node], mm), 0);
        bool r_res = better(eval(line, tree[node], rr), 0);

        if(m_res) swap(line, tree[node]);
        if(l_res == r_res) return;

        create_child(node);

        if(l_res != m_res) _add(line, lid[node], l, m);
        else _add(line, lid[node] + 1, m + 1, r);
    }

    long long _get(int idx, int node, int l, int r) {
        int m = l + (r - l) / 2;
        long long res = eval(tree[node], p[idx]);
        if(!lid[node]) return res;
        else if(idx <= m) return op(res, _get(idx, lid[node], l, m));
        else return op(res, _get(idx, lid[node] + 1, m + 1, r));
    }

    void add(T line) { _add(line, 0, 0, n - 1); }
    long long get(long long x) {
        int idx = lower_bound(p, p + n, x) - p;
        return _get(idx, 0, 0, n - 1);
    }
};
LCT lct;

void solve(int tt) {
    cout<<"Case #"<<tt<<": "<<endl;

}

vll p[MAXN];
ll dp[MAXN];
ll ps[MAXN];
int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n;
    cin>>n;
    rep(i,0,n) {
        p[i]=vll(3);
        cin>>p[i][0]>>p[i][1]>>p[i][2];
    }
    sort(p,p+n);

    rep(i,0,n) ps[i] = p[i][1];
    lct.init(ps,ps+n);

    rep(i,0,n) {
        dp[i]=p[i][0] * p[i][1] - p[i][2] + max(0LL, lct.get(p[i][1]));
        pll line={-p[i][0], dp[i]};
        lct.add(line);
    }
    cout<<*max_element(dp,dp+n)<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

// long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 1e6+50;
// mt19937 rng1(chrono::steady_clock::now().time_since_epoch().count());

template<class T = pair<long long, long long>>
class LCT{
public:
    int n, n_nodes;
    T tree[MAXN * 4];
    long long p[MAXN]; // position of all possible evaluation points
    // int lid[MAXN];
    // Right node's index is always 1 + left node's index
    // lid[i] = 0 means no left node generated.

    long long INF = -(1LL<<60);
    inline long long eval(const T & line, long long x) { return line.first * x + line.second; }
    inline bool better(long long x, long long y) { return x > y; }
    inline long long op(long long x, long long y) { return max(x, y); }

    template<class Iterator>
    void init(Iterator begin, Iterator end) {
        n = end - begin; // std::distance(begin, end);
        for(int i = 0; i < n; i++) p[i] = *(begin + i);
        sort(p, p + n);
        n = unique(p, p + n) - p;

        // n_nodes = 1;
        fill(tree, tree + MAXN * 4, T({0, INF}));
    }

    // void create_child(int node) {
    //     if(!lid[node]) {
    //         lid[node] = n_nodes;
    //         tree[n_nodes++] = {0, INF};
    //         tree[n_nodes++] = {0, INF};
    //     }
    // }

    void _add(T & line, int node, int l, int r) {
        // print("add", line, node, l, r);
        int m = l + (r - l) / 2;
        long long ll = p[l], rr = p[r],mm = p[m];

        bool l_res = better(eval(line, ll), eval(tree[node], ll));
        bool m_res = better(eval(line, mm), eval(tree[node], mm));
        bool r_res = better(eval(line, rr), eval(tree[node], rr));

        if(m_res) swap(line, tree[node]);
        if(l_res == r_res) return;

        // create_child(node);

        if(l_res != m_res) _add(line, node * 2, l, m);
        else _add(line, node * 2 + 1, m + 1, r);
    }

    long long _get(int idx, int node, int l, int r) {
        int m = l + (r - l) / 2;
        long long res = eval(tree[node], p[idx]);
        if(l == r) return res;
        else if(idx <= m) return op(res, _get(idx, node * 2, l, m));
        else return op(res, _get(idx, node * 2 + 1, m + 1, r));
    }

    void add(T line) { _add(line, 1, 0, n - 1); }
    long long get(long long x) {
        int idx = lower_bound(p, p + n, x) - p;
        return _get(idx, 1, 0, n - 1);
    }
};
LCT lct;

void solve(int tt) {
    cout<<"Case #"<<tt<<": "<<endl;

}

vll p[MAXN];
ll dp[MAXN];
ll ps[MAXN];
int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n;
    cin>>n;
    rep(i,0,n) {
        p[i]=vll(3);
        cin>>p[i][0]>>p[i][1]>>p[i][2];
    }
    sort(p,p+n);

    rep(i,0,n) ps[i] = p[i][1];
    lct.init(ps,ps+n);

    rep(i,0,n) {
        dp[i]=p[i][0] * p[i][1] - p[i][2] + max(0LL, lct.get(p[i][1]));
        pll line={-p[i][0], dp[i]};
        lct.add(line);
    }
    cout<<*max_element(dp,dp+n)<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;

#pragma GCC optimize("O3")
#ifdef LOCAL
#include "/Users/lbjlc/Desktop/coding/debug_utils.h"
#else
#define print(...) ;
#define printn(...) ;
#define fprint(...) ;
#define fprintn(...) ;
#endif

#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define maxi(x, y) x = max(x, y)
#define mini(x, y) x = min(x, y)
// long long fact(long long n) { if(!n) return 1; return n*fact(n-1); }
// #define endl '\n'
#define solve_testcase int T;cin>>T;for(int t=1;t<=T;t++){solve(t);}

// long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }

typedef unsigned long long ull;
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;
typedef vector<long long> vll;
#define bd(type,op,val) bind(op<type>(), std::placeholders::_1, val)

template<class T>
void make_unique(T & v) {
    sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());
}
int geti() { int x; cin >> x; return x; }
long long getll() { long long x; cin >> x; return x; }
double getd() { double x; cin >> x; return x; }
// pair<int, int> a(geti(), geti()) does not work
// pair<int, int> a({geti(), geti()}) works, since it uses initializer.

const int MAXN = 2e6+50;
// mt19937 rng1(chrono::steady_clock::now().time_since_epoch().count());

template<class T = pair<long long, long long>>
class LCT{
public:
    int n, n_nodes;
    T tree[MAXN];
    long long p[MAXN]; // position of all possible evaluation points
    int lid[MAXN];
    // Right node's index is always 1 + left node's index
    // lid[i] = 0 means no left node generated.

    long long l0 = -1e9, r0 = 1e9, INF = -(1LL<<60);
    long long eval(const T line, long long x) { return line.first * x + line.second; }
    bool better(long long x, long long y) { return x > y; }
    long long op(long long x, long long y) { return max(x, y); }

    template<class Iterator>
    void init(Iterator begin, Iterator end) {
        n = end - begin; // std::distance(begin, end);
        for(int i = 0; i < n; i++) p[i] = *(begin + i);
        sort(p, p + n);
        n = unique(p, p + n) - p;

        n_nodes = 1;
        tree[0] = {0, INF};

        memset(lid, 0, sizeof(lid));
    }

    void create_child(int node) {
        if(!lid[node]) {
            lid[node] = n_nodes;
            tree[n_nodes++] = {0, INF};
            tree[n_nodes++] = {0, INF};
        }
    }

    void _add(T & line, int node, int l, int r) {
        // print("add", line, node, l, r);
        int m = l + (r - l) / 2;
        int ll=p[l],rr=p[r],mm=p[m];

        bool l_res = better(eval(line, ll), eval(tree[node], ll));
        bool m_res = better(eval(line, mm), eval(tree[node], mm));
        bool r_res = better(eval(line, rr), eval(tree[node], rr));

        if(m_res) swap(line, tree[node]);
        if(l_res == r_res) return;

        create_child(node);

        if(l_res != m_res) _add(line, lid[node], l, m);
        else _add(line, lid[node] + 1, m + 1, r);
    }

    long long _get(int idx, int node, int l, int r) {
        int m = l + (r - l) / 2;
        long long res = eval(tree[node], p[idx]);
        if(!lid[node]) return res;
        else if(idx <= m) return op(res, _get(idx, lid[node], l, m));
        else return op(res, _get(idx, lid[node] + 1, m + 1, r));
    }

    void add(T line) { _add(line, 0, 0, n - 1); }
    long long get(long long x) {
        int idx = lower_bound(p, p + n, x) - p;
        return _get(idx, 0, 0, n - 1);
    }
};
LCT lct;

void solve(int tt) {
    cout<<"Case #"<<tt<<": "<<endl;

}

vll p[MAXN];
ll dp[MAXN];
ll ps[MAXN];
int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // solve_testcase;

    int n;
    cin>>n;
    rep(i,0,n) {
        p[i]=vll(3);
        cin>>p[i][0]>>p[i][1]>>p[i][2];
    }
    sort(p,p+n);

    rep(i,0,n) ps[i] = p[i][1];
    lct.init(ps,ps+n);

    rep(i,0,n) {
        dp[i]=p[i][0] * p[i][1] - p[i][2] + max(0LL, lct.get(p[i][1]));
        pll line={-p[i][0], dp[i]};
        lct.add(line);
    }
    cout<<*max_element(dp,dp+n)<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, m;
	char a[51][51];
	cin >> n >> m;
	int k_i1, k_j1, k_i2, k_j2;
	int cnt = 0;
	int temp_cnt = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
            if (a[i][j] == '*') cnt++;
		}
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if (a[i][j] == '*') {
					temp_cnt++;
		            if (temp_cnt == 1) {
					    k_i1 = i;
					    k_j1 = j;
				    }
				    if (temp_cnt == cnt) {
					  k_i2 = i;
					  k_j2 = j;
				    }
				}
			for (int i = k_i1; i <= k_i2; i++) {
				for (int j = k_j1; j <= k_j2; j++)
					cout << a[i][j];
				cout << endl;
			}
	return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, m;
	char a[51][51];
	cin >> n >> m;
	int k_i1, k_j1, k_i2;
	int k_j2 = 0;
	int cnt = 0;
	int temp_cnt = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
            if (a[i][j] == '*') cnt++;
		}
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if (a[i][j] == '*') {
					temp_cnt++;
		            if (temp_cnt == 1) {
					    k_i1 = i;
					    k_j1 = j;
				    }
					if (j < k_j1) k_j1 = j;
                    if (j > k_j2) k_j2 = j;
				    if (temp_cnt == cnt) k_i2 = i;
				}
			for (int i = k_i1; i <= k_i2; i++) {
				for (int j = k_j1; j <= k_j2; j++)
					cout << a[i][j];
				cout << endl;
			}
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main(){
    int n;
    cin>>n;
    int m;
    cin>>m;
    char a[51][51];
    for(int i = 1; i<=n;i++){
        for(int j = 1; j<=m;j++)
            cin>>a[i][j];
    }

    int max[51];
    int imax[51];
    for(int i = 1; i<=n; i++){
        max[i] = 51;
        for(int j = m; j>=1; j--)
            if(a[i][j] =='*') {

                max[i] = j;

            }

    }

    for(int i = 1; i<=n; i++){
        imax[i] = -1;
        for(int j = 1; j<=m; j++)
            if(a[i][j] =='*') {imax[i] = j;}
    }

            int min[51];
            int imin[51];
            for(int j = 1; j<=m;j++){
                min[j] = 51;
                for(int i = n; i>=1;i--)
                    if(a[i][j] =='*'){min[j] = i; }
            }

            for(int j = 1; j<=m;j++){
                imin[j] = -1;
                for(int i = 1; i<=n;i++)
                    if(a[i][j] =='*'){imin[j] = i; }
            }

                    int c = 51;
                    for(int i = 1; i<=n;i++)
                        if(max[i]<c) c = max[i];

                    int x = -1;
                    for(int i = 1; i<=n; i++)
                        if(imax[i]>x) x = imax[i];

                    int d = 51;
                    for(int j = 1; j<=m; j++)
                        if(min[j]<d) d = min[j];

                    int v = -1;
                    for(int j = 1; j<=m; j++)
                        if(imin[j]>v) v = imin[j];

                    for(int i = d; i<=v; i++){
                        for(int j = c; j<=x; j++){
                            cout<<a[i][j];
                        }
                        cout<<endl;
                    }

                    return 0;
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<string> a(n+1);
    bool q[51];
    for(int i = 0;i<n;i++){
        cin>>a[i];
        q[i] = true;
    }
    int c = 0;

        for(int j = 0;j < m;j++)
            if(a[0][j] == '.') c++;
        if(c == m) q[0] = false;
        else q[0] = true;
        c = 0;

int i = 0;
while(q[i]==false){
        for(int j = 0;j < m;j++)
            if(a[i+1][j] == '.') c++;
        if(c == m) q[i+1] = false;
        else q[i+1] = true;
        c = 0;
        i++;
}
 c = 0;

        for(int j = 0;j < m;j++)
            if(a[n-1][j] == '.') c++;
        if(c == m) q[n-1] = false;
        else q[n-1] = true;
        c = 0;

int d = n-1;
while(q[d]==false){
        for(int j = 0;j < m;j++)
            if(a[d-1][j] == '.') c++;
        if(c == m) q[d-1] = false;
        else q[d-1] = true;
        c = 0;
        d--;
}
    int k = 0;
    for(int j = 0; j < m;j++){
        for(int i = 0; i < n; i++)
            if(a[i][j] == '.') k++;
        if(k == n){
            for(int i = 0; i < n; i++)
                a[i].erase(j,1);
            m--;
            j--;
        }
        k = 0;
    }

    for(int i = 0; i < n; i++)
        if(q[i] == true) cout<<a[i]<<endl;

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<string> a(n+1);
    bool q[51];
    for(int i = 0;i<n;i++){
        cin>>a[i];
        q[i] = true;
    }
    int c = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0;j < m;j++)
            if(a[i][j] == '.') c++;
        if(c == m) q[i] = false;
        else q[i] = true;
        c = 0;
    }
    int k = 0;
    for(int j = 0; j < m;j++){
        for(int i = 0; i < n; i++)
            if(a[i][j] == '.') k++;
        if(k == n){
            for(int i = 0; i < n; i++)
                a[i].erase(j,1);
            m--;
            j--;
        }
        k = 0;
    }
    for(int i = 0; i < n; i++)
        if(q[i] == true) cout<<a[i]<<endl;

    return 0;
}


# define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <string>
#include <map>
#include <ctime>
#include <list>
#include <stack>
#include <set>
#include <memory.h>
#include <deque>
#include <queue>
#include <cctype>
#include <iomanip>

typedef long long ll;
using namespace std;

# define pi 2*acos(0.)
# define e exp(1.)

# define fup(i,n) for(int i=1;i<=n;++i)
# define fdo(i,n) for(int i=n;i>0;--i)
# define N 60

int n,m,k,ans=0,i,j;
int mini, maxi, minj, maxj;

char a[N][N];

int main(){

    cin >> n >> m;
    mini=minj = INT_MAX;
    maxi = maxj = 0;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            if (a[i][j] == '*'){
                if (i < mini)
                    mini = i;
                if (j < minj)
                    minj = j;
                if (j > maxj)
                    maxj = j;
                if (i > maxi)
                    maxi = i;
            }

        }
    }

    for (int i = mini; i <= maxi; ++i){
        for (int j = minj; j <= maxj; ++j)
            cout << a[i][j];
        cout << endl;
    }

    return 0;
}


# define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <string>
#include <map>
#include <ctime>
#include <list>
#include <stack>
#include <set>
#include <memory.h>
#include <deque>
#include <queue>
#include <cctype>
#include <iomanip>

typedef long long ll;
using namespace std;

# define pi 2*acos(0.)
# define e exp(1.)

# define fup(i,n) for(int i=1;i<=n;++i)
# define fdo(i,n) for(int i=n;i>0;--i)
# define N 60

ll n,m,k,ans=0,i,j;

string s;
char a[N][N];
int a1, b1, a2, b2;

int main(){
    int x = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j){
            cin >> a[i][j];
            if (!x&&a[i][j] == '*')
                a1 = i, b1 = j, x = 1;
            if (x&&a[i][j] == '*')
                a2 = i, b2 = j;

        }

    for (int i = a1; i <= a2; ++i){
        for (int j = b1; j <= b2; ++j)
            cout << a[i][j];
        cout << endl;
    }

    return 0;
}


# define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <string>
#include <map>
#include <ctime>
#include <list>
#include <stack>
#include <set>
#include <memory.h>
#include <deque>
#include <queue>
#include <cctype>
#include <iomanip>

typedef long long ll;
using namespace std;

# define pi 2*acos(0.)
# define e exp(1.)

# define fup(i,n) for(int i=1;i<=n;++i)
# define fdo(i,n) for(int i=n;i>0;--i)
# define N 60

int n,m,k,ans=0,i,j;
int minn1, minn2, maxx1, maxx2;

char a[N][N];

int main(){

    cin >> n >> m;
    minn1 = minn2 = N;
    maxx1 = maxx2 = -N;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            if (a[i][j] == '*')
                if (i < minn1&&j < minn2)
                    minn1 = i, minn2 = j;

        }
    }

    for (int i = 0; i < n; ++i){
        for (int j = 0; j < m; ++j){
            if (a[i][j] == '*')
                if (i >=maxx1&&j >= maxx2)
                    maxx1 = i, maxx2 = j;

        }
    }

    for (int i = minn1; i <= maxx1; ++i){
        for (int j = minn2; j <= maxx2; ++j)
            cout << a[i][j];
        cout << endl;
    }

    return 0;
}


// 132132.cpp : Defines the entry point for the console application.
//

#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    char buf[100];
    int n,m;
    gets(buf);
    char s[100][100];
    sscanf(buf,"%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
     gets(s[i]);
    }
    vector<int>x;
    vector<int> y;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            if (s[i][j]=='*')
            {

                x.push_back(i);
                y.push_back(j);
            }
        }

    for(int i=*min_element(x.begin(),x.end());i<=*max_element(x.begin(),x.end());i++)
    {
        for(int j=*min_element(y.begin(),y.end());j<=*max_element(y.begin(),y.end());j++)
        {
            printf("%c",s[i][j]);
        }
        printf("\n");
    }

}


// 132132.cpp : Defines the entry point for the console application.
//

#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    char buf[100];
    int n,m;
    gets(buf);
    char s[100][100];
    sscanf(buf,"%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
     gets(s[i]);
    }
    vector<int>x;
    vector<int> y;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            if (s[i][j]=='*')
            {

                x.push_back(i);
                y.push_back(j);
            }
        }

    for(int i=*min_element(x.begin(),x.end());i<=*max_element(x.begin(),x.end());i++)
    {
        for(int j=*min_element(y.begin(),y.end());j<=*max_element(y.begin(),y.end());j++)
        {
            printf("%c",s[i][j]);
        }
        printf("\n");
    }

}


// 132132.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include<vector>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    char buf[100];
    int n,m;
    gets(buf);
    char s[100][100];
    sscanf(buf,"%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
     gets(s[i]);
    }
    vector<int>x;
    vector<int> y;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            if (s[i][j]=='*')
            {

                x.push_back(i);
                y.push_back(j);
            }
        }

    for(int i=*min_element(x.begin(),x.end());i<=*max_element(x.begin(),x.end());i++)
    {
        for(int j=*min_element(y.begin(),y.end());j<=*max_element(y.begin(),y.end());j++)
        {
            printf("%c",s[i][j]);
        }
        printf("\n");
    }

}


#include <iostream>
using namespace std;

int main(){
    int n,m;                        //rows and collumns
    char** draw;                    //array of drawing
    int min_i,max_i,min_j,max_j;    //limitation of the drawing
    bool flag=true;
    //input
    cin>>m>>n;
    while(n<1 || n>50 || m<1 || m>50){
        cin>>n>>m;
    }
    draw=new char*[n];
    for(int i=0;i<n;i++)
        draw[i]=new char[m];

    for(int j=0;j<m;j++)
        for(int i=0;i<n;i++)
            cin>>draw[i][j];

    //process
    for(int j=0;j<m;j++){
        for(int i=0;i<n;i++){
            if(draw[i][j]=='*' && flag){
                min_i=i;
                min_j=j;
                max_i=i;
                max_j=j;
                flag=false;
            }
            if(draw[i][j]=='*' && i<min_i)
                min_i=i;
            if(draw[i][j]=='*' && i>max_i)
                max_i=i;
            if(draw[i][j]=='*' && j>max_j)
                max_j=j;
        }
    }

    //output
    for(int j=min_j;j<=max_j;j++){
        for(int i=min_i;i<=max_i;i++)
            cout<<draw[i][j];
        cout<<endl;
    }
    return 0;
}


int main(){
    int n,m;                        //rows and collumns
    char** draw;                    //array of drawing
    int min_i,max_i,min_j,max_j;    //limitation of the drawing
    bool flag=true;
    //input
    cin>>m>>n;
    while(n<1 || n>50 || m<1 || m>50){
        cin>>n>>m;
    }
    draw=new char*[n];
    for(int i=0;i<n;i++)
        draw[i]=new char[m];

    for(int j=0;j<m;j++)
        for(int i=0;i<n;i++)
            cin>>draw[i][j];

    //process
    for(int j=0;j<m;j++){
        for(int i=0;i<n;i++){
            if(draw[i][j]=='*' && flag){
                min_i=i;
                min_j=j;
                max_i=i;
                max_j=j;
                flag=false;
            }
            if(draw[i][j]=='*' && i<min_i)
                min_i=i;
            if(draw[i][j]=='*' && i>max_i)
                max_i=i;
            if(draw[i][j]=='*' && j>max_j)
                max_j=j;
        }
    }

    //output
    for(int j=min_j;j<=max_j;j++){
        for(int i=min_i;i<=max_i;i++)
            cout<<draw[i][j];
        cout<<endl;
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;
int main()
{
    int line, col;
    while (cin >> line >> col)
    {
        string str;
        vector <string> vec;
        bool erase = true;
        for (size_t i = 0; i < line; i++)
        {
            cin >> str;
            vec.push_back(str);
        }
        int temp = 0;
        for (size_t i = 0; i < col - temp;)
        {
            erase = true;
            for (size_t j = 0; j < line; j++)
            {
                if (vec[j][i] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)
            {
                for (size_t x = 0; x < line; x++)
                    vec[x].erase(i, 1);
                temp++;
            }
            else
                i++;
        }
        for (size_t i = 0; i < line; i++)
        {
            erase = true;
            for (size_t j = 0; j < vec[i].size(); j++)
            {
                if (vec[i][j] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)  vec[i].clear();
        }
        for (size_t i = 0; i < vec.size(); i++)
        if (vec[i] != "")
            cout << vec[i] << endl;
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <iterator>
using namespace std;
int main()
{
    int line, col;
    while (cin >> line >> col)
    {
        string str;
        vector <string> vec;
        bool erase = true;
        for (size_t i = 0; i < line; i++)
        {
            cin >> str;
            vec.push_back(str);
        }
        int temp = 0;
        for (size_t i = 0; i < col - temp;)
        {
            erase = true;
            for (size_t j = 0; j < line; j++)
            {
                if (vec[j][i] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)
            {
                for (size_t x = 0; x < line; x++)
                    vec[x].erase(i, 1);
                temp++;
            }
            else
                break;
        }
        for (size_t i = vec[vec.size() - 1].size() - 1; i >= 0; i--)
        {
            erase = true;
            for (size_t j = 0; j <vec.size(); j++)
            {
                if (vec[j][i] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)
            for (size_t x = 0; x < vec.size(); x++)
                vec[x].erase(i, 1);
            else
                break;
        }
        for (size_t i = 0; i < line; i++)
        {
            erase = true;
            for (size_t j = 0; j < vec[i].size(); j++)
            {
                if (vec[i][j] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)  vec[i].clear();
            else
                break;
        }
        for (size_t i = vec.size() - 1; i >= 0; i--)
        {
            erase = true;
            for (size_t j = 0; j < vec[i].size(); j++)
            {
                if (vec[i][j] == '*')
                {
                    erase = false;
                    break;
                }
            }
            if (erase)
                vec[i].clear();
            else
                break;
        }
        for (size_t i = 0; i < vec.size(); i++)
        if (vec[i] != "")
            cout << vec[i] << endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main() {
    int row,col,f_row,l_row,f_col,l_col;
    bool fin_ = false;
    char arr[51][51];
    scanf("%d%d",&row, &col);
    for(int i = 0; i < row; i ++)
        for(int j = 0; j < col; j ++) {
            cin >> arr[i][j];
            if(!fin_ && arr [i][j] == '*') {
                f_row = i;
                f_col = j;
                fin_ = true;
            }
            if(arr[i][j] == '*'){
                l_row = i;
                l_col = j;
            }
        }
        //printf("%d %d %d %d\n", f_row,l_row,f_col,l_col);
        for(int i = f_row; i <= l_row; i ++){
            for(int j = f_col; j <= l_col ; j ++)
                cout << arr[i][j];
            cout <<endl;
        }
        return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main() {
    int row,col,f_row = 55,l_row = 0,f_col = 55,l_col = 0;
    bool fin_ = false;
    char arr[51][51];
    scanf("%d%d",&row, &col);
    for(int i = 0; i < row; i ++)
        for(int j = 0; j < col; j ++) {
            cin >> arr[i][j];
            if(arr[i][j] == '*'){
                f_row = min( i, f_row);
                f_col = min( j, f_col);
                l_row = max( i,l_row);
                l_col = max( j,l_col);
            }
        }
        for(int i = f_row; i <= l_row; i ++){
            for(int j = f_col; j <= l_col ; j ++)
                cout << arr[i][j];
            cout <<endl;
        }
        return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main() {
    int row,col,f_row = 55,l_row = 0,f_col = 55,l_col = 0;
    bool fin_ = false;
    char arr[51][51];
    scanf("%d%d",&row, &col);
    for(int i = 0; i < row; i ++)
        for(int j = 0; j < col; j ++) {
            cin >> arr[i][j];
            if(arr[i][j] == '*'){
                f_row =min( i, f_row);
                f_col =min( j, f_col);
                l_row = i;
                l_col = j;
            }
        }
        for(int i = f_row; i <= l_row; i ++){
            for(int j = f_col; j <= l_col ; j ++)
                cout << arr[i][j];
            cout <<endl;
        }
        return 0;
}


#include<iostream>
using namespace std;

int main() {
    int r, c;
    cin >> r >> c;
    char arr[50][50];
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++)
            cin >> arr[i][j];
    }

    int rmin = r, rmax = 0, cmin = c, cmax = 0;
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(arr[i][j] == '*') {
                if(j < cmin) cmin = j;
                if(j > cmax) cmax = j;
                if(i < rmin) rmin = i;
                if(i > rmax) rmax = i;
            }
        }
    }

    if(cmin <= cmax && rmin <= rmax) {
        for(int i = rmin; i <= rmax; i++) {
            for(int j = cmin; j <= cmax; j++) {
                cout << arr[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}


#include<iostream>
using namespace std;

int main() {
    int r, c;
    cin >> r >> c;
    char arr[50][50];
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++)
            cin >> arr[i][j];
    }

    int rmin = r, rmax = 0, cmin = c, cmax = 0;
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(arr[i][j] == '*') {
                if(j < cmin) cmin = j;
                if(j > cmax) cmax = j;
                if(i < rmin) rmin = i;
                if(i > rmax) rmax = i;
            }
        }
    }

    if(cmin <= cmax && rmin <= rmax) {
        for(int i = rmin; i <= rmax; i++) {
            for(int j = cmin; j <= cmax; j++) {
                cout << arr[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<iostream>
using namespace std;

int main() {
    int r, c;
    cin >> r >> c;
    char arr[50][50];
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++)
            cin >> arr[i][j];
    }

    int rmin = r, rmax = 0, cmin = c, cmax = 0;
    for(int i = 0; i < r; i++) {
        for(int j = 0; j < c; j++) {
            if(arr[i][j] == '*') {
                if(j < cmin) cmin = j;
                if(j > cmax) cmax = j;
                if(i < rmin) rmin = i;
                if(i > rmax) rmax = i;
            }
        }
    }

    if(cmin <= cmax && rmin <= rmax) {
        for(int i = rmin; i < rmax; i++) {
            for(int j = cmin; j < cmax; j++) {
                cout << arr[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<stdio.h>
#define MAX_L 50

int main(int argc,char*argv[]){
	FILE* fin,*fout;
	int n,m;

	char garbage;
	int lm,um,dm,rm;
	char matr[50][50];
	//fin=fopen("input.in","r");
	//fout=fopen("output.out","w");
	scanf("%d%d",&n,&m);
	for(unsigned t=0;t<n;++t){
		scanf("%s%c",matr[t],&garbage);
	}
	um=n; lm=m; dm=-1;rm=-1;
	for(int r=0;(r<n);++r){
		for(int c=0;c<m;++c)
			if(matr[r][c]=='*'){
				if(r<um)
					um=r;
				if(r>dm)
					dm=r;
				if(c>rm)
					rm=c;
				if(c<lm)
					lm=c;
			}
	}
	if(um==n)
		return 0;
	for(unsigned r=um;r<=dm;++r){
		for(unsigned c=lm;c<=rm;++c)
			printf("%c",matr[r][c]);
		printf("\n");
	}
	//if(!fin)
	//	fclose(fin);
	//if(!fout)
	//	fclose(fout);
	return 0;
}


#include<stdio.h>
#define MAX_L 50

int main(int argc,char*argv[]){
	FILE* fin,*fout;
	int n,m;

	char garbage;
	int lm,um,dm,rm;
	char matr[60][60];
	//fin=fopen("input.in","r");
	//fout=fopen("output.out","w");
	scanf("%d%d",&n,&m);
	for(unsigned t=0;t<n;++t){
		scanf("%s%c",matr[t],&garbage);
	}
	um=n; lm=m; dm=-1;rm=-1;
	for(int r=0;(r<n);++r){
		for(int c=0;c<m;++c)
			if(matr[r][c]=='*'){
				if(r<um)
					um=r;
				if(r>dm)
					dm=r;
				if(c>rm)
					rm=c;
				if(c<lm)
					lm=c;
			}
	}
	if(um==n)
		return 0;
	for(unsigned r=um;r<=dm;++r){
		for(unsigned c=lm;c<=rm;++c)
			printf("%c",matr[r][c]);
		printf("\n");
	}
	//if(!fin)
	//	fclose(fin);
	//if(!fout)
	//	fclose(fout);
	return 0;
}


#include<stdio.h>
#define MAX_L 50

int main(int argc,char*argv[]){
	FILE* fin,*fout;
	int n,m;

	char garbage;
	int lm,um,dm,rm;
	char matr[50][50];
	//fin=fopen("input.in","r");
	//fout=fopen("output.out","w");
	scanf("%d%d",&n,&m);
	for(unsigned t=0;t<n;++t){
		scanf("%s%c",matr[t],&garbage);
	}
	um=n; lm=m; dm=-1;rm=-1;
	ended=0;
	for(int r=0;(r<n);++r){
		for(int c=0;c<m;++c)
			if(matr[r][c]=='*'){
				if(r<um)
					um=r;
				if(r>dm)
					dm=r;
				if(c>rm)
					rm=c;
				if(c<lm)
					lm=c;
			}
	}
	if(um==n)
		return 0;
	for(unsigned r=um;r<=dm;++r){
		for(unsigned c=lm;c<=rm;++c)
			printf("%c",matr[r][c]);
		printf("\n");
	}
	//if(!fin)
	//	fclose(fin);
	//if(!fout)
	//	fclose(fout);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

ll EPS = 1LL << 60;
double PI = 3.14159265358979323846;

__int64 abss(__int64 h)
{
  if (h < 0)
  {
    return -h;
  }
  return h;
}

__int64 ceill(__int64 x, __int64 y)
{
  if (x % y != 0)
  {
    return (x / y) + 1;
  }
  return x / y;
}

ll n, m, k;

const int MAXN = 1000010;

int a[100][100];

int convert(int n,int base)
{
    int sum = 0;
    while (n != 0)
    {
        sum += n % base;
        n = n / base;
    }
    return sum;
}

int gcd (int a, int b) {
	return b ? gcd (b, a % b) : a;
}

int main()
{
	//freopen("island2.in", "r", stdin);
	//freopen("island2.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	char c;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> c;
			if (c == '*')
			{
				a[i][j] = 1;
			}
		}
	}
	int indNL = 1;
	int indML = 1;
	int indNR = n;
	int indMR = m;
	while (true)
	{
		int r = 0;
		for (int i = 0; i < m; i++)
		{
			if (a[indNL][i] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indNL++;
	}
	while (true)
	{
		int r = 0;
		for (int i = 0; i < m; i++)
		{
			if (a[indNR][i] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indNR--;
	}
	while (true)
	{
		int r = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i][indML] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indML++;
	}
	while (true)
	{
		int r = 0;
		for (int i = 0; i < n; i++)
		{
			if (a[i][indMR] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indMR--;
	}
	for (int i = indNL; i <= indNR; i++)
	{
		for (int j = indML; j <= indMR; j++)
		{
			if (a[i][j] == 1)
			{
				cout << "*";
			}
			else
			{
				cout << ".";
			}
		}
		cout << "\n";
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

ll EPS = 1LL << 60;
double PI = 3.14159265358979323846;

__int64 abss(__int64 h)
{
  if (h < 0)
  {
    return -h;
  }
  return h;
}

__int64 ceill(__int64 x, __int64 y)
{
  if (x % y != 0)
  {
    return (x / y) + 1;
  }
  return x / y;
}

ll n, m, k;

const int MAXN = 1000010;

int a[100][100];

int convert(int n,int base)
{
    int sum = 0;
    while (n != 0)
    {
        sum += n % base;
        n = n / base;
    }
    return sum;
}

int gcd (int a, int b) {
	return b ? gcd (b, a % b) : a;
}

int main()
{
	//freopen("island2.in", "r", stdin);
	//freopen("island2.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	char c;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> c;
			if (c == '*')
			{
				a[i][j] = 1;
			}
		}
	}
	int indNL = 1;
	int indML = 1;
	int indNR = n;
	int indMR = m;
	while (true)
	{
		int r = 0;
		for (int i = 1; i <= m; i++)
		{
			if (a[indNL][i] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indNL++;
	}
	while (true)
	{
		int r = 0;
		for (int i = 1; i <= m; i++)
		{
			if (a[indNR][i] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indNR--;
	}
	while (true)
	{
		int r = 0;
		for (int i = 1; i <= n; i++)
		{
			if (a[i][indML] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indML++;
	}
	while (true)
	{
		int r = 0;
		for (int i = 1; i <= n; i++)
		{
			if (a[i][indMR] == 1)
			{
				r = 1;
				break;
			}
		}
		if (r == 1)
		{
			break;
		}
		indMR--;
	}
	for (int i = indNL; i <= indNR; i++)
	{
		for (int j = indML; j <= indMR; j++)
		{
			if (a[i][j] == 1)
			{
				cout << "*";
			}
			else
			{
				cout << ".";
			}
		}
		cout << "\n";
	}
}


#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <iterator>
#include <algorithm>
#include <list>
#include<fstream>
using namespace std;
#define SZ(X) (int)(X.size())

int main()
{
	string s;
	int p,n,num1=0,num2=0,num3=0;
	cin >> s ;
	n = SZ(s) ;
	if(s[0] >= s[1])
	{
		p =0;
		if(s[2] > s[0])
			p = 2;
	}
	else
	{
		if(s[1] >= s[2])
			p = 1;
		else
			p = 2;
	}
	if(n > 9)
		cout << -1 ;
	else if(s[p] == '0')
	{
		if(n > 3)
			cout << -1 ;
		else
			cout << 0 ;
	}
	else
	{
		for(int i=p; i<n+p-2; i++)
			num1 = (num1*10) + (s[i] - '0') ;
		if(p == 0)
		{
			num2 = s[n-1] - '0' ;
			num3 = s[n-2] - '0' ;
		}
		else if(p == 1)
		{
			num2 = s[0] - '0' ;
			num3 = s[n-1] - '0' ;
		}
		else
		{
			num2 = s[1] - '0' ;
			num3 = s[0] - '0' ;
		}
		if(num1 > 1000000)
			cout << -1 ;
		else
			cout<< num1+num2+num3 ;
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <memory.h>
using namespace std;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()

const double EPS = 1e-9;
const int INF = 1<<28;
const long long INFL = 1LL<<62;

int main()
{
    int n,m,x1,x2,y1,y2 ;
    cin>> n >> m ;
    vector<string> sheet ;
    string line ;
    while(--n)
    {cin >> line; sheet.push_back(line);}

    bool flag = true ; int i=0;
    while(flag && i<n)
    {
        for(int j=0; j<m ; ++j)
            if(sheet[i][j] == '*')
            {x1 = i; y1 = j; flag = false; break;}
        i++;
    }

    flag = true; i = n-1 ;
    while(flag && i>=0)
    {
        for(int j=m-1; j>=0; --j)
            if(sheet[i][j] == '*')
            {x2 = i; y2 = j; flag = false; break;}
        i--;
    }

    for(int i=x1; i<=x2; ++i)
        cout << sheet[i].substr(y1,y2) << endl ;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
using namespace std;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()

const double EPS = 1e-9;
const int INF = 1<<28;
const long long INFL = 1LL<<62;

string board[51] ;
int C ,R ;
int main()
{
	cin >> R >> C ;
	for(int i=0; i<R; ++i)
		cin >> board[i] ;
	int mnR = INF , mnC = INF , mxR = -1 , mxC = -1 ;
	for(int i=0; i<R; ++i)
	{
		for(int j=0; j<C; ++j)
		{
			if(board[i][j] == '*')
				mnR = min(mnR,i) , mnC = min(mnC,j) , mxR = max(mxR,i) , mxC = max(mxC,j) ;
		}
	}
	for(int i=mnR; i<=mxR; ++i)
	{
		for(int j=mnC; j<=mxC; ++j)
			cout<< board[i][j] ;
		cout << endl ;
	}
	system("pause") ;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
using namespace std;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()

const double EPS = 1e-9;
const int INF = 1<<28;
const long long INFL = 1LL<<62;

string board[51] ;
int C ,R ;
int main()
{
	cin >> R >> C ;
	for(int i=0; i<R; ++i)
		cin >> board[i] ;
	int mnR = INF , mnC = INF , mxR = -1 , mxC = -1 ;
	for(int i=0; i<R; ++i)
	{
		for(int j=0; j<C; ++j)
		{
			if(board[i][j] == '*')
				mnR = min(mnR,i) , mnC = min(mnC,j) , mxR = max(mxR,i) , mxC = max(mxC,j) ;
		}
	}
	for(int i=mnR; i<=mxR; ++i)
	{
		for(int j=mnC; j<=mxC; ++j)
			cout<< board[i][j] ;
		cout << endl ;
	}
	return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define X first
#define Y second
#define sz(s) (int)(s).size()
#define mpmake_pair

using namespace std;

typedef long long li;
typedef pair<int, int> pt;
int n, m;
char a[200][200];
int main(){
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    cin >> n >> m;
    pt mn = pt(n, m), mx = pt(0, 0);
    forn(i, n)
        forn(j, m){
            cin >> a[i][j];
            if(a[i][j] == '*'){
                mn = min(mn, pt(i, j));
                mx = max(mx, pt(i, j));
            }
        }
    for(int i = mn.X; i <= mx.X; i++){
        for(int j = mn.Y; j <= mx.Y; j++)
            cout << a[i][j];
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define X first
#define Y second
#define sz(s) (int)(s).size()
#define mpmake_pair

using namespace std;

typedef long long li;
typedef pair<int, int> pt;
int n, m;
char a[200][200];
int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    cin >> n >> m;
    pt mn = pt(n, m), mx = pt(0, 0);
    forn(i, n)
        forn(j, m){
            cin >> a[i][j];
            if(a[i][j] == '*'){
                mn.X = min(mn.X, i);
                mn.Y = min(mn.Y, j);

                mx.X = max(mx.X, i);
                mx.Y = max(mx.Y, j);
            }
        }
    for(int i = mn.X; i <= mx.X; i++){
        for(int j = mn.Y; j <= mx.Y; j++)
            cout << a[i][j];
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define X first
#define Y second
#define sz(s) (int)(s).size()
#define mpmake_pair

using namespace std;

typedef long long li;
typedef pair<int, int> pt;
int n, m;
char a[200][200];
int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    cin >> n >> m;
    pt mn = pt(n, m), mx = pt(0, 0);
    forn(i, n)
        forn(j, m){
            cin >> a[i][j];
            if(a[i][j] == '*'){
                mn = min(mn, pt(i, j));
                mx = max(mx, pt(i, j));
            }
        }
    for(int i = mn.X; i <= mx.X; i++){
        for(int j = mn.Y; j <= mx.Y; j++)
            cout << a[i][j];
        cout << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main (){
        char a[1001][1001];
        int n,m,i,j,min_i,min_j,max_i,max_j;
        cin>>n>>m;
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        cin>>a[i][j];
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        if(a[i][j]=='*')
        {min_i=i; goto x;}
        x:
        for(j=1;j<=m;j++)
        for(i=1;i<=n;i++)
        if(a[i][j]=='*')
        {min_j=j; goto y;}
        y:
        for(i=n;i>=0;i--)
        for(j=m;j>=0;j--)
        if(a[i][j]=='*')
        {max_i=i; goto z;}
        z:
        for(j=m;j>=0;j--)
        for(i=n;i>=0;i--)
        if(a[i][j]=='*')
        {max_j=j; goto t;}
        t:
        for(i=min_i;i<=max_i;i++)
        {for(j=min_j;j<=max_j;j++)
        cout<<a[i][j];
        cout<<endl;}

         //system ("pause");
         return 0;
}


#include <iostream>
using namespace std;
int main (){
        char a[51][51];
        int n,m,i,j,min_i,min_j,max_i,max_j;
        cin>>n>>m;
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        cin>>a[i][j];
        for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        if(a[i][j]=='*')
        {min_i=i; goto x;}
        x:
        for(j=1;j<=m;j++)
        for(i=1;i<=n;i++)
        if(a[i][j]=='*')
        {min_j=j; goto y;}
        y:
        for(i=n;i>=0;i--)
        for(j=m;j>=0;j--)
        if(a[i][j]=='*')
        {max_i=i; goto z;}
        z:
        for(j=m;j>=0;j--)
        for(i=n;i>=0;i--)
        if(a[i][j]=='*')
        {max_j=j; goto t;}
        t:
        for(i=min_i;i<=max_i;i++)
        {for(j=min_j;j<=max_j;j++)
        cout<<a[i][j];
        cout<<endl;}

         //system ("pause");
         return 0;
}


#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
    int n, m, i, j, a, b, c, d, fl;
    char first_x, last_x;
    string s[50];
    cin >> n >> m;
    for (i = 0; i < n; i = i + 1) {
        cin >> s[i];
    }
    first_x = s[0][0];
    a = 0;
    b = 0;
    fl = 0;
    for (i = 0; i < n; i = i + 1) {
        for (j = 0; j < m; j = j + 1) {
            if (s[i][j] == '*') {
                first_x = s[i][j];
                a = i;
                b = j;
                fl = 1;
                break;
            }
        }
        if (fl == 1) {
            break;
        }
    }
    last_x = first_x;
    c = a;
    d = b;
    for (i = a; i < n; i = i + 1) {
        for (j = b; j < m; j = j + 1) {
            if (s[i][j] == '*') {
                last_x = s[i][j];
                c = i;
                d = j;
            }
        }
    }
    for (i = a; i <= c; i = i + 1) {
        for (j = b; j <= d; j = j + 1) {
            cout << s[i][j];
        }
        cout << endl;
    }
}


#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main() {
	int n, m, i, j, a, b, c, d, fl;
	char first_x, last_x;
	string s[50];
	cin >> n >> m;
	for (i = 0; i < n; i = i + 1) {
		cin >> s[i];
	}
	first_x = s[0][0];
	a = 0;
	b = 0;
	fl = 0;
	for (i = 0; i < n; i = i + 1) {
		for (j = 0; j < m; j = j + 1) {
			if (s[i][j] == '*') {
				first_x = s[i][j];
				a = i;
				b = j;
				fl = 1;
				break;
			}
		}
		if (fl == 1) {
			break;
		}
	}
	last_x = first_x;
	c = a;
	d = b;
	for (i = a; i < n; i = i + 1) {
		for (j = b; j < m; j = j + 1) {
			if (s[i][j] == '*') {
				last_x = s[i][j];
				c = i;
				if (j > d) {
					d = j;
				}
			}
		}
	}
	for (i = a; i <= c; i = i + 1) {
		for (j = b; j <= d; j = j + 1) {
			cout << s[i][j];
		}
		cout << endl;
	}
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++){
		for(int q=minc;q<maxc;q++){
printf("%c",s[p][q]);
		}
		printf("\n");
	}	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
#endif

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++)
		for(int q=minc;q<maxc;maxc++){
printf("%c",s[p][q]);

printf("\n");
		}
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){

	int n,m;
	string s[100];
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++,cout<<"\n")
		for(int q=minc;q<maxc;maxc++)
			cout<<s[p][q];
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
string s[100];
cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<=maxr;p++){
		for(int q=minc;q<=maxc;q++){
cout<<s[p][q];		}
		cout<<"\n";

	}	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef long long lint;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

char s[55][55];

int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
#endif
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; ++i) {
		scanf("%s", s[i]);
	}
	int minr = n, maxr = 0, minc = m, maxc = 0;
	for(int r = 0; r < n; ++r)
		for(int c = 0; c < m; ++c) {
			if(s[r][c] == '*') {
				minr = min(minr, r);
				maxr = max(maxr, r);
				minc = min(minc, c);
				maxc = max(maxc, c);
			}
		}
	for(int r = minr; r <= maxr; ++r) {
		for(int c = minc; c <= maxc; ++c) {
			printf("%c", s[r][c]);
		}
		printf("\n");
	}
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++)
		for(int q=minc;q<maxc;q++){
printf("%c",s[p][q]);

printf("\n");
		}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <string>
using namespace std;
typedef vector<int> vint;
typedef long long lint;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

char s[55][55];

int main(){
	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
#endif

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++)
		for(int q=minc;q<maxc;maxc++){
printf("%c",s[p][q]);

printf("\n");
		}
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
string s[100];
cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<=maxr;p++){
		for(int q=minc;q<=maxc;q++){
cout<<s[p][q];		}

	}	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
string s[100];
cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++){
		for(int q=minc;q<maxc;q++){
cout<<s[p][q];		}
cout<<"\n";
	}	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++,cout<<"\n")
		for(int q=minc;q<maxc;maxc++)
printf("%c",s[p][q]);
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[55][55];
int main(){
	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
#endif

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++)
		for(int q=minc;q<maxc;maxc++){
printf("%c",s[p][q]);

printf("\n");
		}
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++)
		for(int q=minc;q<maxc;maxc++){
printf("%c",s[p][q]);

printf("\n");
		}
	return 0;
}


#include<iostream>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){

	int n,m;
	string s[100];
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++) scanf("%s",s[i]);
int minr=n,maxr=0,minc=m,maxc=0;
for(int r=0;r<n;r++)
	for(int c=0;c<m;c++){
		if(s[r][c]=='*'){
		minr=min(minr,r);
			maxr=max(maxr,r);
			minc=min(minc,c);
			maxc=max(maxc,c);
		}
	}
	for(int p=minr;p<maxr;p++){
		for(int q=minc;q<maxc;q++){
printf("%c",s[p][q]);
		}
		printf("\n");
	return 0;
}


# include <iostream>
# include <string>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    string v[50];
    int maxi=0,maxj=0,mini=n,minj=m;
    for( int i=0 ; i<n ; i++)
    {
             cin>>v[i];
    }
    for( int i=0 ; i<n ; i++)
    {
        for( int j=0 ; j<m ; j++)
         {
             if(v[i].at(j)=='*')
             {
                 if(i>maxi)
                     maxi=i;
                 if(i<mini)
                     mini=i;
                 if(j>maxj)
                     maxj=j;
                 if(j<minj)
                     minj=j;
             }
         }
      }
    for( int i=mini ; i<=maxi ; i++)
        {
            for( int j=minj; j<=maxj ; j++)
            {
                cout<<v[i].at(j);
            }
cout<<endl;
        }
        return 0;
}


# include <iostream>
# include <string>
using namespace std;
int main()
{
    int n, m;
    cin>>n>>m;
    string v[50];
    int maxi=0,maxj=0,mini=n,minj=m;
    for( int i=0 ; i<n ; i++)
    {
             cin>>v[i];
    }
    for( int i=0 ; i<n ; i++)
    {
        for( int j=0 ; j<m ; j++)
         {
             if(v[i].at(j)=='*')
             {
                 if(i>maxi)
                     maxi=i;
                 if(i<mini)
                     mini=i;
                 if(j>maxj)
                     maxj=j;
                 if(j<minj)
                     minj=j;
             }
         }
      }
    for( int i=mini ; i<=maxi ; i++)
        {
            for( int j=minj; j<=maxj ; j++)
            {
                cout<<v[i].at(j);
            }
        }
        return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <memory>

using namespace std;

struct dot {
    int x, y;
};

bool cmp2 ( dot a, dot b){
    return (b.y > a.y);

}

bool cmp ( dot a, dot b){
    if ( b.x != a.x) return ( b.x > a.x);
    return (b.y > a.y);

}
int main ( ) {

    int n, m;
    int i,j;
    dot t;
    char mm[55][55];
    memset(mm,0,sizeof(mm));
    char c;
    scanf("%d%d",&n,&m);
    vector <dot> map;

    for ( i = 0; i < n; i++){
        scanf("\n");
        for ( j = 0; j < m; j++){
            scanf("%c",&c);
            mm[i][j] = c;
            if ( c == '*') {
                t.x = i; t.y = j;
                map.push_back(t);
            }
        }
    }

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }
    printf("\n");
*/
    sort(map.begin(),map.end(),cmp);
    int a = map[0].x;
    int b = map[map.size()-1].x;

    sort(map.begin(),map.end(),cmp2);

    int C = map[0].y;
    int d = map[map.size()-1].y;

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }

    printf("%d %d %d %d\n",map[0].x, map[0].y,map[map.size()-1].x, map[map.size()-1].y);
*/
    for ( i = a; i <= b; i++){
        for ( j = C; j <= d; j++){
            printf("%c",mm[i][j]);
        }
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <memory>

using namespace std;

struct dot {
    int x, y;
};

bool cmp ( dot a, dot b){
    if ( b.x != a.x) return ( b.x > a.x);
    return (b.y > a.y);

}
int main ( ) {

    int n, m;
    int i,j;
    dot t;
    char mm[55][55];
    memset(mm,0,sizeof(mm));
    char c;
    scanf("%d%d",&n,&m);
    vector <dot> map;

    for ( i = 0; i < n; i++){
        scanf("\n");
        for ( j = 0; j < m; j++){
            scanf("%c",&c);
            mm[i][j] = c;
            if ( c == '*') {
                t.x = i; t.y = j;
                map.push_back(t);
            }
        }
    }

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }
    printf("\n");
*/
    sort(map.begin(),map.end(),cmp);

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }

    printf("%d %d %d %d\n",map[0].x, map[0].y,map[map.size()-1].x, map[map.size()-1].y);
*/
    int a = map[0].x;
    int b = map[map.size()-1].x;
    int C = map[0].y;
    int d = map[map.size()-1].y;

    for ( i = a; i <= b; i++){
        for ( j = C; j <= d; j++){
            printf("%c",mm[i][j]);
        }
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <stdlib>
#include <memory>

using namespace std;

struct dot {
    int x, y;
};

bool cmp ( dot a, dot b){
    if ( b.x != a.x) return ( b.x > a.x);
    return (b.y > a.y);

}
int main ( ) {

    int n, m;
    int i,j;
    dot t;
    char mm[51][51];
    memset(mm,0,sizeof(mm));
    char c;
    scanf("%d%d",&n,&m);
    vector <dot> map;

    for ( i = 0; i < n; i++){
        scanf("\n");
        for ( j = 0; j < m; j++){
            scanf("%c",&c);
            mm[i][j] = c;
            if ( c == '*') {
                t.x = i; t.y = j;
                map.push_back(t);
            }
        }
    }

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }
    printf("\n");
*/
    sort(map.begin(),map.end(),cmp);

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }

    printf("%d %d %d %d\n",map[0].x, map[0].y,map[map.size()-1].x, map[map.size()-1].y);
*/
    int a = map[0].x;
    int b = map[map.size()-1].x;
    int C = map[0].y;
    int d = map[map.size()-1].y;

    for ( i = a; i <= b; i++){
        for ( j = C; j <= d; j++){
            printf("%c",mm[i][j]);
        }
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>
#include <memory>

using namespace std;

struct dot {
    int x, y;
};

bool cmp ( dot a, dot b){
    if ( b.x != a.x) return ( b.x > a.x);
    return (b.y > a.y);

}
int main ( ) {

    int n, m;
    int i,j;
    dot t;
    char mm[51][51];
    memset(mm,0,sizeof(mm));
    char c;
    scanf("%d%d",&n,&m);
    vector <dot> map;

    for ( i = 0; i < n; i++){
        scanf("\n");
        for ( j = 0; j < m; j++){
            scanf("%c",&c);
            mm[i][j] = c;
            if ( c == '*') {
                t.x = i; t.y = j;
                map.push_back(t);
            }
        }
    }

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }
    printf("\n");
*/
    sort(map.begin(),map.end(),cmp);

/*  for (i = 0; i<map.size(); i++){
        printf("%d %d\n",map[i].x, map[i].y);
    }

    printf("%d %d %d %d\n",map[0].x, map[0].y,map[map.size()-1].x, map[map.size()-1].y);
*/
    int a = map[0].x;
    int b = map[map.size()-1].x;
    int C = map[0].y;
    int d = map[map.size()-1].y;

    for ( i = a; i <= b; i++){
        for ( j = C; j <= d; j++){
            printf("%c",mm[i][j]);
        }
        printf("\n");
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <hash_map>
#include <map>
#include <hash_set>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long LL;
#define mems(arr, val) memset(arr, val, sizeof(arr));
#define iterat(A) A.begin(), A.end()
#define forn(from, to) for(int i = from; i < to; ++i)
#define INF 2000000000

struct skobka
{
	char val;
	int pos;
};

int main()
{
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m;
	cin>>n>>m;
	int min_left = n + 1, min_up = m + 1, max_right = -1, max_down = -1;
	vector<vector<char>> A(n, vector<char> (m));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin>>A[i][j];
			if (A[i][j] == '*')
			{
				min_left = min(min_left, j);
				min_up = min(min_up, i);
				max_right = max(max_right, j);
				max_down = max(max_down, i);
			}
		}
	}

	for (int i = min_up; i <= max_down; ++i)
	{
		for (int j = min_left; j <= max_right; ++j)
		{
			cout<<A[i][j];
		}

		cout<<endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <hash_map>
#include <map>
#include <hash_set>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long LL;
#define mems(arr, val) memset(arr, val, sizeof(arr));
#define iterat(A) A.begin(), A.end()
#define forn(from, to) for(int i = from; i < to; ++i)
#define INF 2000000000

struct skobka
{
	char val;
	int pos;
};

int main()
{
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	int n,m;
	cin>>n>>m;
	int min_left = m + 1, min_up = n + 1, max_right = -1, max_down = -1;
	vector<vector<char>> A(n, vector<char> (m));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			cin>>A[i][j];
			if (A[i][j] == '*')
			{
				min_left = min(min_left, j);
				min_up = min(min_up, i);
				max_right = max(max_right, j);
				max_down = max(max_down, i);
			}
		}
	}

	for (int i = min_up; i <= max_down; ++i)
	{
		for (int j = min_left; j <= max_right; ++j)
		{
			cout<<A[i][j];
		}

		cout<<endl;
	}

	return 0;
}