#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N = 310;
int n, m;
int g[N][N];
int dist[N];
bool st[N];
int prim(){
memset(dist, 0x3f, sizeof dist);
int res = 0;
int MAX = 0;
for (int i = 0; i < n; i ++ ){
int t = -1;
for (int j = 1; j <= n; j ++ )
if (!st[j] && (t == -1 || dist[j] < dist[t]))
t = j;
if (i && dist[t] == INF) return INF;
if (i) res += dist[t], MAX = max(MAX, dist[t]);
st[t] = true;
for (int j = 1; j <= n; j ++ )
dist[j] = min(dist[j], g[t][j]);
}
return MAX;
}
int main(){
cin >> n >> m;
memset(g, 0x3f, sizeof g);
while (m -- ){
int a, b, c;
cin >> a >> b >> c;
g[a][b] = g[b][a] = min(g[a][b], c);
}
cout << n - 1 << ' ' << prim() << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
using namespace std;
const int N = 1e5 + 10;
int n, m, k, x;
int qmi(int a, int k, int p){
int res = 1 % p;
while (k){
if (k & 1) res = (LL)res * a % p;
a = (LL)a * a % p;
k >>= 1;
}
return res;
}
int main(){
cin >> n >> m >> k >> x;
cout << (x + m * qmi(10, k, n)) % n << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
int n;
int main(){
LL res = 0;
cin >> n;
for (; n >= 3; n -- )
res += n * (n - 1);
cout << res << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define lowbit(x) -x&x
#define LL long long
using namespace std;
const int N = 1e5 + 10;
int g[50][50];
int n;
int main(){
cin >> n;
int cnt = 1;
int x = 1, y = (n + 1) / 2;
while (cnt <= n * n){
g[x][y] = cnt;
if (x == 1 && y != n) x = n, y ++ ;
else if (y == n && x != 1) y = 1, x -- ;
else if (x == 1 && y == n) x ++ ;
else if (x != 1 && y != n){
if (!g[x-1][y+1]) x -- , y ++ ;
else x ++ ;
}
cnt ++ ;
}
for (int i = 1; i <= n; i ++ ){
for (int j = 1; j <= n; j ++ )
cout << g[i][j] << ' ';
cout << endl;
}
return 0;
}