#include <bits/stdc++.h>
using namespace std;

#define int long long
#define mod 998244353
#define pb push_back
#define S second
#define F first
#define inf 1e18
#define all(v) v.begin(), v.end()

#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n" \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int pwmd(int n, int m) {
  int res = 1;
  while (m > 0) {
    if (m & 1)
     res = (res % mod * n % mod) % mod;
    m /= 2;
    n = (n % mod * n % mod) % mod;
    }
  return res;
}

int32_t main() {

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a,b,c;
  cin >> a >> b >> c;
  int ans = (a * (a + 1)) / 2;
  ans %= mod;
  ans = (ans * ((b * (b + 1)) % mod *pwmd(2,mod-2) % mod) % mod) % mod;
  ans = (ans * ((c * (c + 1)) % mod *pwmd(2,mod-2) % mod) % mod) % mod;
  cout << ans;
  return 0;
}

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")




int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, i, j, k, ans, nn, INF = 1LL << 60, v;
	cin >> n;
	nn = 1LL << n;
	vector<long long> x(n), y(n), z(n);
	for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
	vector<vector<long long>> dist(n, vector<long long>(n));
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) dist[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]) + max(0LL, z[j] - z[i]);
	}

	vector<vector<long long>> dp(nn, vector<long long>(n, INF));	// dp[bit mask][last city]
	dp[1][0] = 0;
	for (i = 1; i < nn; i++) {
		for (j = 0; j < n; j++) {
			if ((1LL << j) & i) {
				for (k = 0; k < n; k++) {
					if (((1LL << k) & i) == 0) {
						v = i | (1LL << k);
						dp[v][k] = min(dp[v][k], dp[i][j] + dist[j][k]);
					}
				}
			}
		}
	}

	ans = INF;
	for (i = 1; i < n; i++) ans = min(ans, dp[nn - 1][i] + dist[i][0]);
	cout << ans << "\n";


	return 0;
}


