#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e6 + 10;
int a[4];
int main()
{
IOS
for(int i=0;i<4;i++) cin>>a[i];
sort(a,a+4);
if(a[0]+a[1]>a[2]||a[1]+a[2]>a[3]) cout<<"TRIANGLE"<<endl;
else if(a[0]+a[1]==a[2]||a[1]+a[2]==a[3]) cout<<"SEGMENT"<<endl;
else cout<<"IMPOSSIBLE"<<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e2 + 10;
char a[N][N];
int main()
{
IOS
int n;
ll sum = 0;
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> a[i][j];
for (int i = 1; i <= n; i++)
{
int c = 0;
for (int j = 1; j <= n; j++)
if (a[i][j] == 'C') c++;
sum += c * (c - 1) / 2;
}
for (int j = 1; j <= n; j++)
{
int c = 0;
for (int i = 1; i <= n; i++)
if (a[i][j] == 'C') c++;
sum += c * (c - 1) / 2;
}
cout << sum << endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e2 + 10;
int n, a[10], k;
void dfs(int s) {
if (s == n) {
for (int i = 1; i <= n; i++)
cout << a[i] << " ";
cout << endl;
return ;
}
for (int i = 1; i <= k; i++) {
a[s + 1] = i;
dfs(s + 1);
}
}
int main() {
cin >> n >> k;
dfs(0);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e2 + 10;
int n, a[15], k;
void dfs(int s) {
if (s == n) {
for (int i = 1; i <= n; i++)
a[i] ? cout << 'Y' : cout << 'N';
cout << endl;
return ;
}
for (int i = 0; i <= 1; i++) {
a[s + 1] = i;
dfs(s + 1);
}
}
int main() {
IOS
cin >> n;
dfs(0);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull p[30];
int n, k;
void input() {
cin >> n >> k;
for(int i=0; i<n; i++) {
int c, x;
cin >> c;
while(c--) {
cin >> x;
p[i] |= (1ULL << (k - x)); // 人士 i 拥有 x 能力,修改对应 bit
}
}
}
int choice[30];
ull ans;
void dfs(int pos) {
if(pos == n) {
ull res = 0;
for(int i=0; i<n; i++)
if(choice[i])
res ^= p[i];
ans = max(res, ans);
return;
}
choice[pos] = 0;
dfs(pos + 1);
choice[pos] = 1;
dfs(pos + 1);
}
void work() {
dfs(0);
cout << ans << endl;
}
int main() {
input();
work();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define ios ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N = 1e2 + 10;
int n, a[10], k;
bool b[10];
void dfs(int s) {
if (s == n) {
for (int i = 1; i <= n; i++)
cout << a[i] << " ";
cout << endl;
return ;
}
for (int i = 1; i <= k; i++) {
if(!b[i]){
a[s + 1] = i;
b[i]=true;
dfs(s + 1);
b[i]=false;
}
}
}
int main() {
IOS
cin >> k >> n;
dfs(0);
return 0;
}