Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.

The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.

Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int i,a,b,c;
    int t[6];

    for (i=0;i<4;i++)
        scanf ("%d",&t[i]);

    t[4]=t[0];
    t[5]=t[1];
    char* msg="IMPOSSIBLE";

    //triangle
    for (i=0;i<4;i++)
    {
        a=t[i];
        b=t[i+1];
        c=t[i+2];
        if ((a<b+c)&&(b<a+c)&&(c<a+b))
        {
         msg="TRIANGLE";
        printf("%s\n",msg);
        return(0);

        }
    }

    //segment
    for (i=0;i<4;i++)
    {
        a=t[i];
        b=t[i+1];
        c=t[i+2];
         if ((a==b+c)||(b==c+a)||(c==b+a))
        {
            msg="SEGMENT";
            printf("%s\n",msg);
            return(0);
        }

    }
    printf("%s\n",msg);

    return 0;
}

#include<stdio.h>
int a[5];
int u[4];
int f[5] = {0}, falg=0;
void dfs(int dep)
{
	if (dep == 4)//因为dep是在为下一轮做准备，所以dep=3(准备选第3个数)时才选了2个数，所以要dep=4时来判断
	{
		if (u[1] + u[2]>u[3] && u[1] + u[3]>u[2] && u[2] + u[3]>u[1])
		{
			printf("TRIANGLE");//满足普通三角形，直接输出
			exit(0);//意为"正常退出程序"，相当于主函数里面的retrun 0,在DFS里面用可以节省搜到答案后回朔的时间
		}
		if (u[1] + u[2] >= u[3] && u[1] + u[3] >= u[2] && u[2] + u[3] >= u[1])falg = 1;
		/*
		这里不能直接输出
		因为弱化三角形的优先级小于普通三角形，
		所以当木棍同时满足弱化三角形和普通三角形的条件时应该输出最优解普通三角形
		但因为用的是DFS，枚举数的顺序只和数据的顺序有关，于是满足弱化三角形时就直接输了,要到确认没有普通三角形时才能输
		(第一次竟然在在这里跪了QAQ)
		*/
		return;
	}
	for (int i = 1;i <= 4;i++)
		if (f[i] == 0)
		{
			f[i] = 1;
			u[dep] = a[i];//把当前枚举到的组合临时存储下来
			dep++;//为下轮做准备
			dfs(dep);//刚学DFS时教练说内循环要写成镜像来回溯，于是我沿用到现在
			dep--;//撤销所有操作
			u[dep] = 0;
			f[i] = 0;
		}
}
int main()
{
	scanf("%d%d%d%d", a + 1, a + 2, a + 3, a + 4);//把数组当指针用，小绿书介绍过，也可以写scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4])
	dfs(1);
	if (falg)printf("SEGMENT");//然而第2次又跪在打少了一个等号上(我太蒻了)
	else printf("IMPOSSIBLE");
	return 0;
}

#include<stdio.h>
main() {
    int a,b,c,d,i,j,k;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((a < b+c&&b < a+c&&c < a+b) || ( a < b+d&&b < a+d&&d < a+b ) || ( a < c+d&&d < a+c&&c <a+d ) || ( b < c+d&&d < b+c&&c <b+d ))
	printf("TRIANGLE\n");
    else if((a==b+c || b==a+c || c==a+b) || (a==b+d || b==a+d || d==a+b) || (a==c+d || d==a+c || c==a+d) || (b==c+d || d==b+c || c==b+d))
	printf("SEGMENT\n");
    else
	printf("IMPOSSIBLE\n");
return 0;
}

#include <stdio.h>
int f(const void *a, const void *b)
{
    return ( *(int *)a - *(int *)b );
}
int main()
{
    int a[4], i, flag=0;
    for(i=0;i<4;i++)
    scanf("%d",&a[i]);
    qsort(a,4,sizeof(int),f);
    if( (a[1]+a[0]>a[2]) || (a[1]+a[2]>a[3]) )
    printf("TRIANGLE");
    else if( (a[0]+a[1]==a[2]) || (a[1]+a[2]==a[3]) )
    printf("SEGMENT");
    else
    printf("IMPOSSIBLE");
	return 0;
}

# include<stdio.h>
int a[4] = {0};
int u[4] = {0};
int cc[4];
int triangleFlag = 0;
int segmentFlag = 0;

dfs(int d){
	if (d == 4){
		return;
	}
	if (d == 3){
		if (u[0] + u[1] > u[2] && u[0] + u[2] > u[1] && u[1] + u[2] > u[0]){
			triangleFlag = 1;
		}
		if (u[0] + u[1] >= u[2] && u[0] + u[2] >= u[1] && u[1] + u[2] >= u[0]){
			segmentFlag = 1;
		}
	}
	for (int i = 0; i < 4; i++){
		int temp_flag = 0;
		for (int j = 0; j < 4; j++){
			if (cc[j] == i){
				temp_flag = 1;
				break;
			}
		}
		if (temp_flag){
			continue;
		}
		u[d] = a[i];
		cc[i] = i;
		dfs(++d);
		d--;
		u[d] = 0;
		cc[i] = -1;
	}
}

int main(){
	for (int i = 0; i < 4; i++){
		scanf("%d", a+i);
		cc[i] = -1;
	}
	dfs(0);
	if (triangleFlag){
		printf("TRIANGLE");
	} else if(segmentFlag){
		printf("SEGMENT");
	} else {
		printf("IMPOSSIBLE");
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,k,c;
    scanf("%d%d%d%d",&n,&m,&k,&c);
    if((n+m>k&&m+k>n&&k+n>m)||(m+k>c&&k+c>m&&m+c>k)||(n+m>c&&m+c>n&&n+c>m)||(n+k>c&&k+c>n&&c+n>k))
    {
        printf("TRIANGLE");
        return 0;
    }
    else if((n+m==k||m+k==n||k+n==m)||(m+k==c||k+c==m||m+c==k)||(n+m==c||m+c==n||n+c==m)||(n+k==c||k+c==n||c+n==k))
    {
        printf("SEGMENT");
        return 0;
    }
    else
    {
        printf("IMPOSSIBLE");
        return 0;
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int ara[4];
    for(int i=0;i<4;i++)
        scanf("%d",&ara[i]);
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<3-i;j++)
            if(ara[j]>=ara[j+1])
        {
            int temp=ara[j];
            ara[j]=ara[j+1];
            ara[j+1]=temp;

        }}
        if((ara[0]+ara[1]>ara[2])||(ara[0]+ara[1]>ara[3])||(ara[1]+ara[2]>ara[3])||(ara[0]+ara[2]>ara[3]))
    printf("TRIANGLE");
else if((ara[0]+ara[1]==ara[2])||(ara[0]+ara[1]==ara[3])||(ara[1]+ara[2]==ara[3])||(ara[0]+ara[2]==ara[3]))
    printf("SEGMENT");

    else printf("IMPOSSIBLE");

    return 0;
}

#include<stdio.h>
#include<stdlib.h>

int book[ 4 ], ns[ 4 ];     // 标记是否使用以及存储原四个数据
int ans[ 3 ];               // 判断此时的三个数能否组成三角形
int flag;                   // 标记是否是弱化三角形

void dfs( int dep );

int main(){
    for( int i = 0; i <= 3; i ++ ) scanf("%d", &ns[ i ]);

    dfs( 0 );

    if( flag ) printf("SEGMENT");
    else printf("IMPOSSIBLE");

    return 0;
}

void dfs( int dep ){
    if( dep == 3 ){
        if( ans[ 0 ] + ans[ 1 ] > ans[ 2 ] && ans[ 1 ] + ans[ 2 ] > ans[ 0 ] && ans[ 0 ] + ans[ 2 ] > ans[ 1 ] ){
            printf("TRIANGLE");
            exit( 0 );
        }

        if( ans[ 0 ] + ans[ 1 ] >= ans[ 2 ] && ans[ 1 ] + ans[ 2 ] >= ans[ 0 ] && ans[ 0 ] + ans[ 2 ] >= ans[ 1 ] ){
            flag = 1;
        }

        return ;
    }

    for( int i = 0; i < 4; i ++ ){
        if( book[ i ] == 0 ){
            book[ i ] = 1;
            ans[ dep ] = ns[ i ];

            dfs( ++ dep );

            dep --;
            ans[ dep ] = 0;
            book[ i ] = 0;
        }
    }
}

#include <stdio.h>
#include <stdlib.h>

int cmp(const int *a, const int *b){
   if(*a < *b) return -1;
   if(*a > *b) return 1;
   return 0;
}

int main(){
   int in[4], i;
   for(i = 0; i < 4; ++i) scanf("%d", &in[i]);
   qsort(in, 4, sizeof(int), cmp);

   int j, k, find = 0;
   for(i = 0; i < 4; ++i){
   for(j = i+1; j < 4; ++j){
   for(k = j+1; k < 4; ++k){
      if(find < 2 && in[i] + in[j] > in[k]) find = 2;
      if(find < 1 && in[i] + in[j] == in[k]) find = 1;
   }}}

   if(find == 0) puts("IMPOSSIBLE");
   else if(find == 1) puts("SEGMENT");
   else puts("TRIANGLE");

   return 0;
}

#include <stdio.h>

int a, b, c, d, tz;

int main()
{
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a > b) {tz = a; a = b; b = tz;}
	if(c < a) {tz = c; c = b; b = a; a = tz;}
	else if(c < b) {tz = c; c = b; b = tz;}
	if(d < a) {tz = d; d = c; c = b; b = a; a = tz;}
	else if ( d < b) {tz = d; d = c; c = b; b = tz;}
	else if ( d < c) {tz = d; d = c; c = tz;}

	if (a + b < c && b + c < d) printf("IMPOSSIBLE");
	else if (a + b > c || b + c > d) printf("TRIANGLE");
	else printf("SEGMENT");
}

#include <stdio.h>
#include <math.h>

/**
 *
 * @param a
 * @param b
 * @param c
 * @return -1: nemozne, 0: segment, 1: trojuholnik
 */
int trojuholnik(int a, int b, int c) {
    if (b > c) {
        int tmp = b;
        b = c;
        c = tmp;
    }
    if (a > c) {
        int tmp = a;
        a = c;
        c = tmp;
    }
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    /*printf("%d %d %d", a, b, c);*/

    if (a+b < c) {
        return -1;
    } else if (a+b == c) {
        return 0;
    } else {
        return 1;
    }
}

int main(int argc, char* argv[]) {
    int d1,d2,d3,d4, tmp;
    int result;
    //printf("Zadaj dlzky stran\n");
    /* if (result != 4 ) { */
    while (scanf("%d %d %d %d", &d1, &d2, &d3, &d4) != 4
           || d1 < 0 || d2 < 0 || d3 < 0 || d4 < 0 ) {
        printf("Nespravny vstup\n");
        while (getchar() != '\n') {}
    }
    /*printf("%d %d %d %d", d1, d2, d3, d4);*/
    result = -1;
    tmp = trojuholnik(d1, d2, d3);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d1, d2, d4);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d2, d3, d4);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d1, d3, d4);
    if (tmp > result) result = tmp;
    if (result == 1) {
        printf("TRIANGLE\n");
    } else if (result == 0) {
        printf("SEGMENT\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include <stdio.h>

int main()
{
	int i=0,j;
	int a[4];
	int b ;
	while(i++<= 3)
		scanf("%d", &a[i-1]);
	for (i = 3; i >= 1; i--)
		for (j = 0; j < i; j++)
		{
			if (a[j] > a[j + 1])
			{
				b = a[j];
				a[j] = a[j + 1];
				a[j + 1] = b;
			}
		}
	for (i = 0,b = 0; i < 2; i++)
	{
		if (a[i + 2] < a[i] + a[i + 1])
		{
			printf("TRIANGLE\n");
			return 0;
		}
		if (a[i + 2] == a[i] + a[i + 1])
		{
			b = 1;
		}
	}
    if (b)
		printf("SEGMENT\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

#include<stdio.h>
int s=0,p=0;
int sum(int a,int b,int c)
{
    if(a+b>c && b+c>a && a+c>b)
        {
    s=1;
    return 0;
    }
    if(a+b>=c&&b+c>=a &&c+a>=b)
        {
        p=1;
        return 0;
    }
    return 0;
}

int main(){
    int a[4],i,j,k;
    for(i=0;i<4;i++)
    scanf("%d",&a[i]);
    for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
        {
            for(k=0;k<4;k++)
            {
            if(a[k]+a[j]>=a[i]&&j!=i&&k!=i&&j!=k)
                sum(a[i],a[j],a[k]);
            }
        }
    }
if(s==1){
    printf("TRIANGLE\n");
    return 0;
}
else if(p==1){
    printf("SEGMENT\n");
    return 0;
}
printf("IMPOSSIBLE\n");
return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

void intSort(int d[],int s){int i=-1,j=s,k,t;if(s <= 1)return;k=(d[0] + d[s-1]) / 2;while(1){while(d[++i] < k);while(d[--j] > k);if(i >= j) break;t=d[i];d[i]=d[j];d[j]=t;}intSort(d, i);intSort(d+j+1, s-j-1);}

int main(){
  int i, j, k;
  int in[4];

  rep(i,4) scanf("%d",&in[i]);
  intSort(in,4);
  if(in[3] < in[2] + in[1]){puts("TRIANGLE"); return 0;}
  if(in[2] < in[1] + in[0]){puts("TRIANGLE"); return 0;}
  if(in[3] == in[1] + in[2]){puts("SEGMENT"); return 0;}
  if(in[2] == in[1] + in[0]){puts("SEGMENT"); return 0;}

  puts("IMPOSSIBLE");

  return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmp(const int *a, const int *b)
{
    return *(int*)a-*(int*)b;
}

int tri(int x, int y, int z)
{
    if(((x+y>z) && (y+z>x)) && (x+z>y))
        return 1;
    return 0;
}

int seg(int x, int y, int z)
{
    if(x+y==z)
        {
            //printf("%d %d %d\n",x,y,z);
            return 1;
        }
    return 0;
}
int main()
{
    int i,a[4]={0},flagt=0,flags=0,flagi=0;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
    qsort(a,4,sizeof(int),cmp);
    /*for(i=0;i<4;i++)
        printf("%d ",a[i]);*/
    if(tri(a[0],a[1],a[2]) || tri(a[0],a[1],a[3]) || tri(a[0],a[2],a[3]) || tri(a[1],a[2],a[3]))
        flagt=1;

    else
    {
        if(seg(a[0],a[1],a[2]) || seg(a[0],a[1],a[3]) || seg(a[0],a[2],a[3]) || seg(a[1],a[2],a[3]))
            flags=1;

        else
            flagi=1;
    }
    if(flagt)
        printf("TRIANGLE\n");
    else if(flags)
        printf("SEGMENT\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define N 10
int a[N],get[N],vis[N],flag=1,ans;

void Merge(int a[],int start,int mid,int end)
{
    int *temp = (int *)malloc((end-start+1)*sizeof(int));
    int i=start;
    int j=mid+1;
    int k=0;
    while(i<=mid&&j<=end)
    {
        if(a[i]<a[j])
        {
            temp[k++]=a[i++];
        }
        else
        {
            temp[k++]=a[j++];
        }
    }
    while(i<=mid)
    {
        temp[k++]=a[i++];
    }
    while(j<=end)
    {
        temp[k++]=a[j++];
    }
    for(i=0; i<k; i++)
        a[start+i] = temp[i];
    free(temp);
}

void MergeSort(int a[],int start,int end)
{
    if(start >= end)
        return;
    int mid = start + (end - start)/2;
    MergeSort(a,start,mid);
    MergeSort(a,mid+1,end);
    Merge(a,start,mid,end);
}

int Judge()
{
    //printf("%d %d %d\n",get[1],get[2],get[3]);
    if(get[3]==get[1]+get[2])
        return 0;
    if(get[3]<get[1]+get[2])
        return -1;
    else if(flag==1)
        return 1;
    else
        return 0;
}

void DFS(int step)
{
    if(flag==-1)
        return;
    if(step==4)
    {
        flag = Judge();
        return;
    }
    for (int i=1; i<=4; i++)
    {
        if (vis[i]==0 && a[i] >= get[step-1] ) //保证取值单调递增，满足组合有顺序
        {
            get[step] = a[i];
            vis[i] = 1;
            DFS(step+1);
            vis[i] = 0;
        }
    }

}

int main()
{
    for(int i=1; i<=4; i++)
        scanf("%d",&a[i]);
    MergeSort(a,1,4);
    DFS(1);
    if(flag==-1)
        printf("TRIANGLE\n");
    else if(flag==0)
        printf("SEGMENT\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

#include<stdio.h>
int istriangle(int x,int y, int z)
{
	int flag1=0,flag2=0,flag3=0;
	if(x+y>z)flag1=1;
	if(x+z>y)flag2=1;
	if(y+z>x)flag3=1;
	if(flag1&&flag2&&flag3)return 1;
	flag1=0;
	flag2=0;
	flag3=0;
	if(x+y>=z)flag1=1;
	if(x+z>=y)flag2=1;
	if(y+z>=x)flag3=1;
	if(flag1&&flag2&&flag3)return -1;
	else return 0;
}
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int flag1=0,flag2=0,flag3=0,flag4=0;
	flag1=istriangle(a,b,c);
	flag2=istriangle(a,b,d);
	flag3=istriangle(d,b,c);
	flag4=istriangle(a,d,c);
	if(flag1==1||flag2==1||flag3==1||flag4==1)printf("TRIANGLE");
	else if(flag1==-1||flag2==-1||flag3==-1||flag4==-1)printf("SEGMENT");
	else printf("IMPOSSIBLE");
	return 0;
}

#include <stdio.h>
int main()
{
	int a[5],x,o=10,i,j;
	for (i=1;i<=4;i++){
		scanf ("%d", &a[i]);
	}
	for (i=1;i<=4;i++)
		for (j=1;j<=4;j++)
			for (x=1;x<=4;x++)
			  if(a[j]>=a[i] && a[x]>=a[j] && i!=j && j!=x && i!=x)
			  {
			    if (a[i]+a[j]>a[x])
			      {printf("TRIANGLE\n"); return 0;}
			    if (a[i]+a[j]==a[x])
			      o=2;
			  }
	if(o==2)
	  printf ("SEGMENT\n");
	else
	  printf ("IMPOSSIBLE\n");
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmpfunc(const void *a, const void *b) { return(*(int*)a - *(int*)b); }
int main()
{
int l[4];
scanf("%d%d%d%d",&l[0],&l[1],&l[2],&l[3]);
qsort(l,4,sizeof(int),cmpfunc);
if(l[0]+l[1]>l[2]||l[1]+l[2]>l[3]||l[0]+l[2]>l[3]){
printf("TRIANGLE\n");
}

else if(l[0]+l[1]==l[2]||l[1]+l[2]==l[3]||l[0]+l[2]==l[3]){
printf("SEGMENT\n");
}
else{
printf("IMPOSSIBLE\n");
}
return 0;
}

#include <stdio.h>

int check(int a, int b, int c) {

	if (a + b > c && b + c > a && a + c > b)
		return 1;
	else
		return 0;
}

int check_degen(int a, int b, int c) {
	if (a + b == c || a + c == b || b + c == a)
		return 1;
	else
		return 0;
}

int main(void)
{
	int a; int b; int c; int d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (check(a, b, c) || check(b, c, d) || check(a, c, d) || check(a, b, d)) {
		printf("TRIANGLE\n");
	} else if (check_degen(a, b, c) || check_degen(b, c, d) || check_degen(a, c, d) || check_degen(a, b, d)) {
		printf("SEGMENT\n");
	} else {
		printf("IMPOSSIBLE\n");
	}

	return 0;
}

#include<stdio.h>
#include<stdlib.h>

int a[5];
int b[4];
int flag;

int cmp(void const *a, void const *b)
{
	return *(int *)a < *(int *)b ? -1 : 1;
}
void cal()
{
	if (flag == 1)
	return;
	int z[3];
	for (int i = 1; i <= 3; i++)
	{
		z[i-1] = b[i];
	}
	qsort(z,3,sizeof(z[0]),cmp);
	if (z[0] + z[1] > z[2])
	flag = 1;
	if (z[0] + z[1] == z[2])
	flag = 2;
}
void dfs(int f, int u)
{
	if (u == 4)
	{
		cal();
		return;
	}
	if (f == 5) return;
	b[u] = a[f];
	dfs(f+1,u+1);
	dfs(f+1,u);
}

int main()
{
	for (int i = 1; i <= 4; i++)
	{
		scanf("%d",&a[i]);
	}
	dfs(1,1);
	if (flag == 0)
	printf("IMPOSSIBLE");
	if (flag == 1)
	printf("TRIANGLE");
	if (flag == 2)
	printf("SEGMENT");
	return 0;
}

#include <stdio.h>
int trgl(int a,int b,int c);
void res(int a);
int main(){
    int a, b, c, d,x,y=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    x=trgl(a,b,c);
    if (x>=y)
        y=x;
    x=trgl(a,c,d);
    if (x>=y)
        y=x;
    x=trgl(a,b,d);

    if (x>y)
        y=x;

    x=trgl(b,c,d);
    if (x>=y)
        y=x;
    res(y);
    return 0;
}
int trgl(int a,int b,int c){
    int y;
    if (a+b>c && b+c>a && c+a>b){
        y=3;}
    else if (a+b==c || b+c==a || c+a==b){
        y=2;}
    else{
        y=1;
    }

    return y;
}
void res(int a){
    if (a==3)
        printf("TRIANGLE");
    else if (a==2)
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b>c&&a+c>b&&b+c>a)||(a+d>c&&a+c>d&&d+c>a)||(d+b>c&&d+c>b&&b+c>d)||(a+b>d&&a+d>b&&b+d>a))
        printf("TRIANGLE");
    else if((a+b==c||a+c==b||b+c==a)||(a+d==c||a+c==d||d+c==a)||(d+b==c||d+c==b||b+c==d)||(a+b==d||a+d==b||b+d==a))
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
int main(void)
{
	int length[4];
	int i=0,j=0,a=0,sum=0;
	for(;i<4;i++)
	scanf("%d",&length[i]);
    for(i=0;i<3;i++)
	{
	  for(j=i+1;j<4;j++)
	  {
      if(length[j]<length[i])
        {
	     a=length[i];
	     length[i]=length[j];
		 length[j]=a;
	    }
      }
	}
	if(length[0]+length[1]>length[3]|length[0]+length[1]>length[2]|length[1]+length[2]>length[3])
	  printf("TRIANGLE");
	else
	  if(length[0]+length[1]==length[3]|length[0]+length[1]==length[2]|length[1]+length[2]==length[3])
	    printf("SEGMENT");
	  else
	  printf("IMPOSSIBLE");
	return 0;
}

#include<stdio.h>
int triangle(int a,int b,int c){
    if((a<b+c)&&(b<a+c)&&(c<a+b)) return 1;
    else return 0;
}
int segment(int a,int b,int c){
    if((a==b+c)||(b==a+c)||(c==a+b)) return 1;
    else return 0;
}
int main(){
    int d_triangle=0,t_segment=0;
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    d_triangle=d_triangle||triangle(a,b,c);
    d_triangle=d_triangle||triangle(a,b,d);
    d_triangle=d_triangle||triangle(a,c,d);
    d_triangle=d_triangle||triangle(b,c,d);

    t_segment=t_segment||segment(a,b,c);
    t_segment=t_segment||segment(a,b,d);
    t_segment=t_segment||segment(a,c,d);
    t_segment=t_segment||segment(b,c,d);

    if(d_triangle) printf("TRIANGLE");
    else if(t_segment) printf("SEGMENT");
    else printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
main() {
    int a,b,c,d,i,j,k;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if((a < b+c&&b < a+c&&c < a+b) || ( a < b+d&&b < a+d&&d < a+b ) || ( a < c+d&&d < a+c&&c <a+d ) || ( b < c+d&&d < b+c&&c <b+d ))
	printf("TRIANGLE\n");
    else if((a==b+c || b==a+c || c==a+b) || (a==b+d || b==a+d || d==a+b) || (a==c+d || d==a+c || c==a+d) || (b==c+d || d==b+c || c==b+d))
	printf("SEGMENT\n");
    else
	printf("IMPOSSIBLE\n");
return 0;
}

#include <stdio.h>
#include<string.h>

void ins(int a[], int n)
{
    int i, j, k;
    for (i=1; i<n; i++)
    {
        k=a[i];

        for(j=i-1 ; j>=0 && a[j]<k; j--)
            a[j+1]=a[j];

        a[j+1]=k;
    }
}

int main()
{
    int i, a[4];
    for(i=0;i<4;i++)
        scanf("%d", &a[i]);

    ins(a, 4);

    if((a[3]+a[2])>a[1] || (a[2]+a[1])>a[0])
    {
        printf("TRIANGLE");
        return 0;
    }
    else if((a[3]+a[2])==a[1] || (a[2]+a[1])==a[0])
    {
        printf("SEGMENT");
        return 0;
    }
    else
    {
        printf("IMPOSSIBLE");
        return 0;
    }
}

#include <stdbool.h>
#include "stdio.h"
#include "stdint.h"
#include "string.h"
#include "stdlib.h"

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

bool seg=false, tri=false;

void judge(int a1, int a2, int a3) {
    if (a3<a2) {int z=a3;a3=a2;a2=z;}
    if (a3<a1) {int z=a3;a3=a1;a1=z;}
    if (a1+a2>a3) tri = true;
    if (a1+a2==a3) seg = true;
}

int main() {
    int a,b,c,d;
    scanf("%d %d %d %d", &a,&b,&c,&d);
    judge(a,b,c);
    judge(a,b,d);
    judge(a,c,d);
    judge(b,c,d);
    printf(tri?"TRIANGLE\n":seg?"SEGMENT\n":"IMPOSSIBLE\n");
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    while(scanf(" %d %d %d %d",&a,&b,&c,&d)==4)
    {
        if( (a+b>c && b+c>a && c+a>b) || (a+b>d && b+d>a && d+a>b) || (b+c>d && c+d>b && d+b>c) || (a+c>d && c+d>a && d+a>c) )
            printf("TRIANGLE\n");
        else if (a+b==c || a+c==b || b+c==a || a+b==d || a+d==b || b+d==a || a+c==d || a+d==c || c+d==a || b+c==d || b+d==c || c+d==b)
            printf("SEGMENT\n");
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include <stdio.h>
#include <conio.h>
#include <math.h>
int kiemtra(int x, int y,int z)
{
	if (x+y>z && x+z>y && z+y>x)
	{
	return 1;
	}
	return 0;
}
int bang(int x1, int y1, int z1)
{
	if (x1+y1==z1 || x1+z1==y1 || z1+y1==x1)
	{
	return 1;
	}
	return 0;
}
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if (kiemtra(a,b,c) || kiemtra(a,b,d) || kiemtra(d,b,c) || kiemtra(a,d,c) )
	{
	     printf("TRIANGLE");
	     return 0;
	}
    if (bang(a,b,c) || bang(a,b,d) || bang(d,b,c) || bang(a,d,c) )
	{
	     printf("SEGMENT");
	     return 0;
	}
	else printf("IMPOSSIBLE");

}

#include <stdio.h>
#include <stdlib.h>
#define YES 1
#define NO 0

void prob6A(){
    int i, a, b, c, d, state, state_2;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    int arr[5][5] = {{a, b, c},
        {b, a, d},
        {c, a, d},
        {d, b, c}};

    state  = NO;
    state_2 = NO;
    for (i=0; i<4; i++)
        if ((arr[i][0]<arr[i][1]+arr[i][2]) && (arr[i][1]<arr[i][0]+ arr[i][2]) && (arr[i][2]<arr[i][1]+arr[i][0]))
            state = YES;
    for (i=0; i<4; i++)
            if (arr[i][0]==arr[i][1]+arr[i][2] || arr[i][1]==arr[i][0]+arr[i][2] || arr[i][2]==arr[i][1]+arr[i][0])
                state_2 = YES;

    if (state == YES)
        printf("TRIANGLE");
    else if (state_2 == YES)
        printf("SEGMENT");
    else printf("IMPOSSIBLE");

}

int main()
{   prob6A();
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
void sort(int *arr, int len, int rec)
{
    if(len == 1) return;
    int record = 0;
    for(int i = 0; i < len; ++i)
    {
        if(*(arr + len - 1 - i) > record)
        {
            record = *(arr + len - 1 - i);
            *(arr + len - 1 - i) = *(arr + len - 1);
            *(arr + len - 1) = record;
        }
    }
    ++rec; --len;
    sort(arr, len, rec);
    return;
}

int main()
{
    int arr[4] = {0, 0, 0, 0};

    scanf("%i %i %i %i", &arr[0], &arr[1], &arr[2], &arr[3]);

    sort(&arr[0], 4, 0);

     if(arr[0]+arr[1]>arr[2] || arr[1]+arr[2]>arr[3])
    {
        printf("TRIANGLE\n");
    }
    else if(arr[0]+arr[1]==arr[2] || arr[1]+arr[2]==arr[3])
    {
        printf("SEGMENT\n");
    }
    else
    {
        printf("IMPOSSIBLE\n");
    }

    return 0;
}

#include <stdio.h>

int main() {
    int number[4];
    int i, j, a;
    scanf("%d %d %d %d", &number[0], &number[1], &number[2], &number[3]);

    for (i = 0; i < 4; ++i) {
            for (j = i + 1; j < 4; ++j) {
                if (number[i] < number[j]) {
                    a =  number[i];
                    number[i] = number[j];
                    number[j] = a;
            }
        }
    }
    int temp = 0;
    for (int i = 0; i < 2; ++i) {
        if (number[i] < number[i + 1] + number[i + 2]) {
            printf("TRIANGLE\n");
            return 0;
        } else if (number[i] == number[i + 1] + number[i + 2]) {
            temp = 1;
        }
    }

    if (temp) {
        printf("SEGMENT\n");
    } else {
        printf("IMPOSSIBLE\n");//
    }
    return 0;
}

#include<ctype.h>
#include<limits.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define T1(x, y, z) (x + y > z && abs(x - y) < z)
#define T2(x, y, z) (x + y == z || x + z == y || y + z == x)
int main(void)
{
    int a, b, c, d;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    if(T1(a, b, c) || T1(a, b, d) || T1(a, c, d) || T1(b, c, d))
        printf("TRIANGLE");
    else if(T2(a, b, c) || T2(a, b, d) || T2(a, c, d) || T2(b, c, d))
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");

    return 0;
}

#include <stdio.h>
#include <math.h>
#include <string.h>

int main(){
int arr[4],i,j,k,e=0,c=0,d=0;
for(i=0;i<4;i++){
scanf("%d",&arr[i]);}
for(i=0;i<2;i++){
    for(j=i+1;j<3;j++){
        for(k=j+1;k<4;k++){
            if(arr[i]+arr[j]>arr[k]&&arr[i]+arr[k]>arr[j]&&arr[j]+arr[k]>arr[i]){
                    c++;

            }
            else if(arr[i]+arr[j]==arr[k]||arr[i]+arr[k]==arr[j]||arr[j]+arr[k]==arr[i])
            {
                d++;

            }
            else e++;
        }}}
        if(c!=0)
            printf("TRIANGLE");
        else if(d!=0)
            printf("SEGMENT");
        else
            printf("IMPOSSIBLE");
}

#include<stdio.h>
int main ()
    {
    int a,b,c,d;
     scanf("%d %d %d %d",&a,&b,&c,&d);
         if ((a < b+c && b < a+c && c < a+b) || (a < b+d && b < a+d && d < a+b) || (a < d+c && d < a+c && c < a+d) || (d < b+c && b < d+c && c < d+b))
         printf("TRIANGLE\n");
         else if ((a == b+c || b == a+c || c == a+b) || (a == b+d || b == a+d || d == a+b) || (a == d+c || d == a+c || c == a+d) || (d == b+c || b == d+c || c == d+b))
         printf("SEGMENT\n");
         else  printf("IMPOSSIBLE\n");

     return 0;
    }

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a[4],i,j,k,d=0;
	for(i=0;i<4;i++)
		scanf("%d",&a[i]);
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++){
			if(i==j)
				continue;
			for(k=0;k<4;k++)
			{
				if(i==k || j==k)
					continue;
				if(a[i]<a[j]+a[k] && a[i]>abs(a[j]-a[k]))
				{
					d=1;
					goto c;
				}
				else if(a[i]==a[j]+a[k])
					d=2;

			}
		}

	}
c:
	if(d==1)
		printf("TRIANGLE");
	else if(d==2)
		printf("SEGMENT");
	else
		printf("IMPOSSIBLE");
	return 0;

}

#include<stdio.h>

int main()
{
        int arr[5], i, j, k, flag;
        scanf("%d%d%d%d", &arr[0], &arr[1], &arr[2], &arr[3]);

        for(i = 0; i < 4; i++){
                for(j = i+1; j <4; j++){
                        if(arr[j] >arr[i]){
                                k = arr[i]; arr[i] = arr[j]; arr[j] = k;
                        }
                }
        }
        flag = 0;
        if(arr[0] < (arr[1] + arr[2]) || arr[1] < (arr[2] + arr[3])){
                flag = 1;
        } else if(arr[0] == (arr[1]+arr[2]) || arr[1] == (arr[2]+arr[3])){
                flag = 2;
        }

        if(flag == 0){
                printf("IMPOSSIBLE\n");
        } else if(flag == 1){
                printf("TRIANGLE\n");
        } else if(flag == 2){
                printf("SEGMENT\n");
        }
        return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    int t=0,s=0;
    //int A,B,C;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>=c && a+c>=b && b+c>=a)
    {   if(a+b>c && a+c>b && b+c>a){t=1;}
        else {s=1;}
    }
    if(a+b>=d && a+d>=b && b+d>=a)
    {
       if(a+b>d && a+d>b && b+d>a){t=1;}
        else {s=1;}
    }
    if(a+c>=d && a+d>=c && c+d>=a)
    {
      if(a+c>d && a+d>c && c+d>a){t=1;}
        else {s=1;}
    }
    if(b+c>=d && b+d>=c && c+d>=b)
    {
       if(b+c>d && b+d>c && c+d>b){t=1;}
        else {s=1;}
    }
    if(t==1){printf("TRIANGLE"); return 0;}
    if(s==1){printf("SEGMENT"); return 0;}
    printf("IMPOSSIBLE\n");

    return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b>c&&a+c>b&&b+c>a)||(a+d>c&&a+c>d&&d+c>a)||(d+b>c&&d+c>b&&b+c>d)||(a+b>d&&a+d>b&&b+d>a))
        printf("TRIANGLE");
    else if((a+b==c||a+c==b||b+c==a)||(a+d==c||a+c==d||d+c==a)||(d+b==c||d+c==b||b+c==d)||(a+b==d||a+d==b||b+d==a))
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
int main()
{
    int n,m,k,c;
    scanf("%d%d%d%d",&n,&m,&k,&c);
    if((n+m>k&&m+k>n&&k+n>m)||(m+k>c&&k+c>m&&m+c>k)||(n+m>c&&m+c>n&&n+c>m)||(n+k>c&&k+c>n&&c+n>k))
    {
        printf("TRIANGLE");
        return 0;
    }
    else if((n+m==k||m+k==n||k+n==m)||(m+k==c||k+c==m||m+c==k)||(n+m==c||m+c==n||n+c==m)||(n+k==c||k+c==n||c+n==k))
    {
        printf("SEGMENT");
        return 0;
    }
    else
    {
        printf("IMPOSSIBLE");
        return 0;
    }
    return 0;
}

#import <stdio.h>

int checkTriangle(int num1, int num2, int num3)
{
    if (((num1 + num2) > num3) & ((num2 + num3) > num1) & ((num1 + num3) > num2))
    {
       return 1;
    }
    return 0;
}

int checkSegment(int num1, int num2, int num3)
{
   if ((num1 + num2 == num3) || (num2 +num3 == num1) || (num1 + num3 == num2))
    {
       return 1;
    }
    return 0;
}
int main()
{
   int num[4];

   for (int i = 0; i < 4; i++)
   {
        scanf("%d", &num[i]);
   }

   int t = 0;
   for (int i = 0; i < 4; i ++)
   {
      int a = 0;
      int b = 0;
      if (i + 1 == 4)
      {
         a = 0;
      }
      else
      {
         a = i + 1;
      }
      if (a + 1 == 4)
      {
         b = 0;
      }
      else
      {
         b = a + 1;
      }
      t = checkTriangle(num[i], num[a], num[b]);
      if (t == 1)
      {
         printf("TRIANGLE");
         return 0;
      }
   }

   for (int i = 0; i < 4; i ++)
   {
      int a = 0;
      int b = 0;
      if (i + 1 == 4)
      {
         a = 0;
      }
      else
      {
         a = i + 1;
      }
      if (a + 1 == 4)
      {
         b = 0;
      }
      else
      {
         b = a + 1;
      }
      t = checkSegment(num[i], num[a], num[b]);
      if (t == 1)
      {
         printf("SEGMENT");
         return 0;
      }
   }
      if (t==0)
      {
         printf("IMPOSSIBLE");
      }
}

#include<stdio.h>
int s=0,p=0;
int sum(int a,int b,int c)
{
    if(a+b>c && b+c>a && a+c>b)
        {
    s=1;
    return 0;
    }
    if(a+b>=c&&b+c>=a &&c+a>=b)
        {
        p=1;
        return 0;
    }
    return 0;
}

int main(){
    int a[4],i,j,k;
    for(i=0;i<4;i++)
    scanf("%d",&a[i]);
    for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
        {
            for(k=0;k<4;k++)
            {
            if(a[k]+a[j]>=a[i]&&j!=i&&k!=i&&j!=k)
                sum(a[i],a[j],a[k]);
            }
        }
    }
if(s==1){
    printf("TRIANGLE\n");
    return 0;
}
else if(p==1){
    printf("SEGMENT\n");
    return 0;
}
printf("IMPOSSIBLE\n");
return 0;
}

#include<stdio.h>

int main()
{
    int a,b,c,d,f=-1;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>c&&b+c>a&&a+c>b)
    f=1;
    else if(a+b>d&&a+d>b&&b+d>a)
    f=1;
    else if(a+c>d&&a+d>c&&c+d>a)
    f=1;
    else if(b+d>c&&b+c>d&&c+d>b)
    f=1;
    else if(a+b==c||b+c==a||a+c==b)
    f=0;
    else if(a+b==d||a+d==b||b+d==a)
    f=0;
    else if(a+c==d||a+d==c||c+d==a)
    f=0;
    else if(b+d==c||b+c==d||c+d==b)
    f=0;
    if(f==0)
    printf("%s","SEGMENT");
    else if(f==1)
    printf("%s","TRIANGLE");
    else
    printf("%s","IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
int main(void)
{
    int num,i,j,k,temp;
    int ara[4];
    for(i=0;i<4;i++){
        scanf("%d",&ara[i]);
    }
    for(j=0;j<4;j++){
        for(k=j;k<4;k++){
            if(ara[k]<ara[j]){
                temp=ara[k];
                ara[k]=ara[j];
                ara[j]=temp;
            }
        }
    }
    if(ara[0]+ara[1]>ara[2]||ara[0]+ara[2]>ara[3]||ara[1]+ara[2]>ara[3]){
        printf("TRIANGLE\n");
    }
    else if(ara[0]+ara[1]==ara[2]||ara[0]+ara[2]==ara[3]||ara[1]+ara[2]==ara[3]){
        printf("SEGMENT\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
}

#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void sort ( int * );

int main()
{
int arr[4] ;
int x , y ;

for (int i = 0 ; i < 4 ; i++)
scanf("%d", &arr[i]);

sort(arr);

if(arr[0]+arr[1]>arr[2] || arr[1]+arr[2]>arr[3])
{
    printf("TRIANGLE\n");
}
else if(arr[0]+arr[1]==arr[2] || arr[1]+arr[2]==arr[3])
{
    printf("SEGMENT\n");
}
else
{
    printf("IMPOSSIBLE\n");

}

    return 0;
}

void sort (int *arr){
	int temp;
	for ( int i =0 ; i<4 ; i++){
		for ( int n =0 ; n<4 ; n++){
		if (*(arr+i) < *(arr+n)){
			temp = *(arr+i);
			*(arr+i) = *(arr+n);
			*(arr+n)=temp;
		}

	}
	}
return ;}

#include<stdio.h>

int main(){
int a,b,c,d,m,n,o,p,q,r,s=0;
scanf("%d%d%d%d",&a,&b,&c,&d);
m=a+b,n=b+c,o=c+a,p=a+d,q=b+d,r=c+d;
if(m>c&&n>a&&o>b || n>d&&q>c&&r>b || m>d&&p>b&&q>a || o>d&&p>c&&r>a){
printf("TRIANGLE");
s=1;
}
else if(s!=1){
if(m==c||n==a||o==b||n==d||q==c||r==b||m==d||p==b||q==a||o==d||p==c||r==a){
printf("SEGMENT");
}
else{
printf("IMPOSSIBLE");
}
}

return 0;
}

# include<stdio.h>

int a[4] = {0};
int u[4] = {0};
int flag[4] = {0};
int flag1 = 0;
int flag2 = 0;

void dfs(int d){
	if (d == 4){
		if (u[0] + u[1] > u[2] && u[0] + u[2] > u[1] && u[1] + u[2] > u[0]){
			flag1 = 1;
			return;
		}
		if (u[0] + u[1] >= u[2] && u[0] + u[2] >= u[1] && u[1] + u[2] >= u[0]){
			flag2 = 1;
		}
		return;
	}
	for (int i = 0; i < 4; i++){
		int temp_flag = 0;
		for (int j = 0; j < 4; j++){
			if (flag[j] == i){
				temp_flag = 1;
				break;
			}
		}
		if (temp_flag){
			continue;
		}
		u[d] = a[i];
		flag[i] = i;
		dfs(++d);
		d--;
		u[d] = 0;
		flag[i] = -1;
	}
}

int main(){
	for (int i = 0; i < 4; i++){
		scanf("%d", a+i);
		flag[i] = -1;
	}
	dfs(0);
	if (flag1){
		printf("TRIANGLE");
	} else if (flag2){
		printf("SEGMENT");
	} else {
		printf("IMPOSSIBLE");
	}
	return 0;
}

#include <stdio.h>

int a, b, c, d, tz;

int main()
{
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if(a > b) {tz = a; a = b; b = tz;}
	if(c < a) {tz = c; c = b; b = a; a = tz;}
	else if(c < b) {tz = c; c = b; b = tz;}
	if(d < a) {tz = d; d = c; c = b; b = a; a = tz;}
	else if ( d < b) {tz = d; d = c; c = b; b = tz;}
	else if ( d < c) {tz = d; d = c; c = tz;}

	if (a + b < c && b + c < d) printf("IMPOSSIBLE");
	else if (a + b > c || b + c > d) printf("TRIANGLE");
	else printf("SEGMENT");
}

#include<stdio.h>
int main()
{
    int l[4],i,j,temp;
    for(i=0;i<4;i++){
        scanf("%d",&l[i]);
    }
    for(i=0;i<4;i++){
        for(j=i+1;j<4;j++){
            if(l[j]>l[i]){
                temp=l[i];
                l[i]=l[j];
                l[j]=temp;
            }
        }
    }
    temp=0;
    for(i=0;i<2;i++){
        if(l[i]<l[i+1]+l[i+2]){
            printf("TRIANGLE\n");
            temp=1;
            break;
        }
        else if(l[i]==l[i+1]+l[i+2])
        {
            temp=2;
        }
    }
    if(temp==2){
        printf("SEGMENT\n");
    }
    else if(temp==0){
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int is_triangle(int a,int b,int c)
{
    if(a+b>c&&a+c>b&&b+c>a) return 1;
    else if(a+b>=c&&a+c>=b&&b+c>=a) return 0;
    else return -1;
}
int main()
{
//	freopen("datain.txt","r",stdin);
//	freopen("datain.txt","w",stdout);
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(is_triangle(a,b,c)==1||is_triangle(a,b,d)==1||is_triangle(a,c,d)==1||is_triangle(b,c,d)==1)
        printf("TRIANGLE");
    else if(is_triangle(a,b,c)==0||is_triangle(a,b,d)==0||is_triangle(a,c,d)==0||is_triangle(b,c,d)==0)
        printf("SEGMENT");
    else printf("IMPOSSIBLE");
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}

typedef enum {
	IMPOSSIBLE = 0,
	SEGMENT,
	TRIANGLE
}possible;

possible isTriangle_possible(int x,int y,int z)
{
	if (x + y == z)
		return SEGMENT;
	if(x + z == y)
		return SEGMENT;
	if(z + y == x)
		return SEGMENT;

	if(((x + y) < z) || ((y + z) < x) || ((x + z) < y))
		return IMPOSSIBLE;
	return TRIANGLE;
}
int main()
{
	int x,y,z,p,update = 0;
	int ret = 0;
	char result[][20] = {{"IMPOSSIBLE"},{"SEGMENT"},{"TRIANGLE"}};
	scanf("%d%d%d%d",&x,&y,&z,&p);
	ret = isTriangle_possible(x,y,z);
	if(ret > update)
	{
		update = ret;
		if (update == TRIANGLE)
			goto finish;
	}
	ret = isTriangle_possible(x,y,p);
	if(ret > update)
	{
		update = ret;
		if (update == TRIANGLE)
			goto finish;
	}
	ret = isTriangle_possible(x,p,z);
	if(ret > update)
	{
		update = ret;
		if (update == TRIANGLE)
			goto finish;
	}

	ret = isTriangle_possible(p,y,z);
	if(ret > update)
	{
		update = ret;
		if (update == TRIANGLE)
			goto finish;
	}

finish:
	printf("%s",result[update]);
	return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if((a+b>c&&b+c>a&&a+c>b)||(a+b>d&&b+d>a&&a+d>b)||(a+c>d&&a+d>c&&c+d>a)||(b+c>d&&b+d>c&&c+d>b))
    {
        printf("TRIANGLE");
    }
    else if(a==b+c||a==c+d||a==b+d||b==c+d||b==a+c||b==a+d||c==a+b||c==d+a||c==b+d||d==a+b||d==b+c||d==a+c)
    {
        printf("SEGMENT");
    }
    else
    {
        printf("IMPOSSIBLE");
    }

}

#include<stdio.h>
int s=0,p=0;
int sum(int a,int b,int c)
{
    if(a+b>c && b+c>a && a+c>b)
        {
    s=1;
    return 0;
    }
    if(a+b>=c&&b+c>=a &&c+a>=b)
        {
        p=1;
        return 0;
    }
    return 0;
}

int main(){
    int a[4],i,j,k;
    for(i=0;i<4;i++)
    scanf("%d",&a[i]);
    for(i=0;i<4;i++)
    {
        for(j=0;j<4;j++)
        {
            for(k=0;k<4;k++)
            {
            if(a[k]+a[j]>=a[i]&&j!=i&&k!=i&&j!=k)
                sum(a[i],a[j],a[k]);
            }
        }
    }
if(s==1){
    printf("TRIANGLE\n");
    return 0;
}
else if(p==1){
    printf("SEGMENT\n");
    return 0;
}
printf("IMPOSSIBLE");
return 0;
}

#include <stdio.h>

int main()
{
    int i, j, str[4], temp;
    for(i=0; i<4; i++)
        scanf("%d", &str[i]);

    for(i=0; i<4-1; i++){
        for(j=0; j<4-1; j++){
            if(str[j] > str[j+1]){
                temp = str[j];
                str[j] = str[j+1];
                str[j+1] = temp;
            }
        }
    }

    if(str[0] + str[1] > str[2] || str[1] + str[2] > str[3])
        printf("TRIANGLE");
    else if(str[0] + str[1] == str[2] || str[1] + str[2] == str[3])
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");

    return 0;
}

#include<stdio.h>
int largest(int x, int y, int z)
{
  int c = 0;
  if(x>y && x> z)
  {
      c=x;
  }
  if(y>x && y> z)
  {
      c=y;
  }
  if(z>y && z> x)
  {
      c=z;
  }
  return c;
}
int main()
{
    int p, q, r, s, t,m, n , o;
    scanf("%d %d %d %d", &p, &q, &r, &s);
t=largest(p,q,r);
m=largest(p,q,s);
n=largest(p,r,s);
o=largest(q,r,s);
if(t<((p+q+r)-t) || m<((p+q+s)-m) || n<((p+r+s)-n) || o<((r+q+s)-o))
{
    printf("TRINGLE");
}
else if (t==(p+q+r-t) || n==(p+r+s-n) || m==(p+q+s-m) || o==(r+q+s-o ))
{

    printf("SEGMENT");
}
else
    {
    printf("IMPOSSIBLE");
}
return 0;
}

#import <stdio.h>

int checkTriangle(int num1, int num2, int num3)
{
    if ((num1 + num2 > num3) && (num2 +num3 > num1) && (num1 + num3 > num2))
    {
       return 1;
    }
    return 0;
}

int checkSegment(int num1, int num2, int num3)
{
   if ((num1 + num2 == num3) || (num2 +num3 == num1) || (num1 + num3 == num2))
    {
       return 1;
    }
    return 0;
}
int main()
{
   int num[4];

   for (int i = 0; i < 4; i++)
   {
        scanf("%d", &num[i]);
   }

   int t = 0;
   for (int i = 0; i < 4; i ++)
   {
      int a = 0;
      int b = 0;
      if (i + 1 == 4)
      {
         a = 0;
      }
      else
      {
         a = i +1;
      }
      if (a + 1 == 4)
      {
         b = 0;
      }
      else
      {
         b = b + 1;
      }
      t = checkTriangle(num[i], num[a], num[b]);
      if (t == 1)
      {
         printf("TRIANGLE");
         return 0;
      }
   }

   for (int i = 0; i < 4; i ++)
   {
      int a = 0;
      int b = 0;
      if (i + 1 == 4)
      {
         a = 0;
      }
      else
      {
         a = i +1;
      }
      if (a + 1 == 4)
      {
         b = 0;
      }
      else
      {
         b = b + 1;
      }
      t = checkSegment(num[i], num[a], num[b]);
      if (t == 1)
      {
         printf("SEGMENT");
         return 0;
      }
      else
      {
         printf("IMPOSSIBLE");
      }
   }
}

#include<stdio.h>
int main()
{
    int a,b,c,d,max,ma;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a>b&&a>c&&a>d)
        max=a;
    else if(b>a&&b>c&&b>d)
        max=b;
    else if(c>a&&c>b&&c>d)
        max=c;
    else
        max=d;
        if(max==a)
    if( max<(b+c)||max<(b+d)||max<(c+d))

    {
        if(b<(c+d)||c<(b+d)||d<(b+c))
    {
        printf("SEGMENT");
        return 0;
    }

        printf("TRIANGLE");
            return 0;
    }
    if(max==b)
    if( max<(a+c)||max<(a+d)||max<(c+d))
    {
        if(b<(c+d)||c<(b+d)||d<(b+c))
    {
        printf("SEGMENT");
        return 0;
    }
         printf("TRIANGLE");
            return 0;
    }
    if(max==c)
    if(max<(a+b)||max<(a+d)||max<(b+d))
    {
        if(b<(c+d)||c<(b+d)||d<(b+c))
    {
        printf("SEGMENT");
        return 0;
    }
         printf("TRIANGLE");
            return 0;
    }
    if(max==d)
     if(max<(a+b)||max<(a+c)||max<(b+c))
    {

        if(b<(c+d)||c<(b+d)||d<(b+c))
    {
        printf("SEGMENT");
        return 0;
    }
    printf("TRIANGLE");
            return 0;
    }
    printf("IMPOSSIBLE");
    return 0;

}

#include <stdio.h>
int main()
{
    int i, j, sum, temp, len[4], x=0;

    for(i=0;i<4;i++)
    {
        scanf("%d", &len[i]);
    }
    for(i=0;i<4;i++)
    {
        for(j=i+1;j<4;j++)
        {
            if(len[i]>len[j])
            {
                temp=len[j];
                len[j]=len[i];
                len[i]=temp;
            }
        }
    }
    /*for(i=0;i<4;i++)
    {
        printf("%d\n", len[i]);
    }*/

    sum=len[0]+len[1];
    if(sum<len[2])
    {
        x=0;
    }
    if(sum==len[2])
    {
        x=1;
    }
    if(sum>len[2])
    {
        x=2;
    }
    //printf("x=%d\n", x);
    if(x<2)
    {
        sum=len[1]+len[2];
        if(sum>len[3])
        {
            x=2;
        }
    }

    if(x==0)
    {
        printf("IMPOSSIBLE\n");
    }
    if(x==1)
    {
        printf("SEGMENT\n");
    }
    if(x==2)
    {
        printf("TRIANGLE\n");
    }
    return 0;

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 long long int yo(const void* a,const void* b)
{
   return (*(long long int*)a-*(long long int*)b);

}
int main()
{
    int ch[50000],cp[500000];
    char kh[1000000],arr[1000000];
    long long int a=0,b=0,c,d,e,i=0,j=0,k=0,l=0,tep,temp,m,n,x,y;
    for(i=0; i<4; i++)
        scanf("%lld",&ch[i]);

    qsort(ch,4,sizeof(int),yo);

    if(ch[2]+ch[1]>ch[3])
     printf("TRIANGLE");
    else if(ch[2]+ch[1]<ch[3] && ch[0]+ch[1]==ch[2])
     printf("SEGMENT\n");
    else
     printf("IMPOSSIBLE\n");
    /* for(i=1; j<c; i++)
     {
         j=a+(i*b);
         if(j==c || j+1==c)
         {
             k=1;
             break;
         }
         k=0;
     }*/

 //   printf("%f\n",x*b);

    return 0;
}

#include <stdio.h>

int check(int a, int b, int c)
{
	int ok1 = 0; int ok2 = 0; int ok3 = 0;
	if (a + b > c)
		ok1 = 1;
	if (b + c > a)
		ok2 = 1;
	if (a + c > b)
		ok3 = 1;

	if (ok1 == 1 && ok2 == 1 && ok3 == 1) {
		return 1;
	} else {
		return 0;
	}
}

int check_deg(int a, int b, int c)
{
	if (a + b == c)
		return 1;
	if (b + c == a)
		return 1;
	if (a + c == b)
		return 1;

	return 0;
}

int main(void)
{
	int a; int b; int c; int d;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	if (check(a, b, c) || check(a, b, d) || check(b, c, d)) {
		printf("TRIANGLE\n");
	} else if (check_deg(a, b, c) || check_deg(a, b, d) || check_deg(b, c, d)) {
		printf("SEGMENT\n");
	} else {
		printf("IMPOSSIBLE\n");
	}

	return 0;
}

#include<stdio.h>
int main()
{
    int ara[4];
    for(int i=0;i<4;i++)
        scanf("%d",&ara[i]);
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<3-i;j++)
            if(ara[j]>=ara[j+1])
        {
            int temp=ara[j];
            ara[j]=ara[j+1];
            ara[j+1]=temp;

        }}
if((ara[0]+ara[1]==ara[2])||(ara[0]+ara[1]==ara[3])||(ara[1]+ara[2]==ara[3])||(ara[0]+ara[2]==ara[3]))
    printf("SEGMENT");
else if((ara[0]+ara[1]>ara[2])||(ara[0]+ara[1]>ara[3])||(ara[1]+ara[2]>ara[3])||(ara[0]+ara[2]>ara[3]))
    printf("TRIANGLE");
    else printf("IMPOSSIBLE");

    return 0;
}

#include<stdio.h>
int main()
{
	int i=0,j,k,m=0,s=0,a[4];
	while(i<4)
	{
		scanf("%d",&a[i]);
		i++;
	}
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++)
		{
			for(k=0;k<4;k++)
			{
				if(a[i]+a[j]>a[k])
				s++;
				if(a[i]+a[j]==a[k])
				m++;
			}
		}
	}
	if(s>0)
	printf("TRIANGLE");
	else
	{
		if(m>0)
		printf("SEGEMENT");
		else
		printf("IMPOSSIBLE");
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b<c||a+c<b||b+c<a){
        printf("IMPOSSIBLE");
    }
    else if(a+b==c||a+c==b||b+c==a){
        printf("SEGMENT");
    }
    else{
        printf("TRIANGLE");
    }
}

#include<stdio.h>

int temp[10];				//Temporary array

void mergearray(int i, int mid, int j, int *output)
{
	int p=i, q=mid+1, in=0;
	while((p<=mid) || (q<=j))
	{
		if(p>mid)
		{
			temp[in]=output[q];
			q++;
		}
		else if(q>j)
		{
			temp[in]=output[p];
			p++;
		}
		else if(output[p]<output[q])			//Increasing order
		{
			temp[in]=output[p];
			p++;
		}
		else
		{
			temp[in]=output[q];
			q++;
		}
		in++;
	}
	while(--in>=0)
		output[i+in]=temp[in];
	return;
}

void mergesort(int i, int j, int *output)
{
	if(i==j) return;

	int mid=(i+j)/2;
	mergesort(i, mid, output);
	mergesort(mid+1, j, output);
	mergearray(i, mid, j, output);
}

int main()
{
	int arr[4], i, j, k, flag=0;
	for(i=0; i<4; i++)
		scanf("%d", &arr[i]);
	mergesort(0, 3, arr);
	for(i=0; i<4; i++)
	{
		for(j=0; j<4; j++)
		{
			if(j==i) continue;
			for(k=0; k<4; k++)
			{
				if(k==j || k==i) continue;
				if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j] && arr[j]+arr[k]>arr[i])
				{
					flag=1;
					printf("TRIANGLE: %d %d %d\n", arr[i], arr[j], arr[k]); break;
				}
				else if(arr[i]+arr[j]==arr[k])
				{
					flag=2;
				}
			}
			if(flag==1) break;
		}
		if(flag==1) break;
	}
	if(flag==0)
		printf("IMPOSSIBLE\n");
	else if(flag==2)
		printf("SEGMENT\n");
	return 0;
}

#include<stdio.h>
int main()
{
    int a[4],i,j,k,p,c=0;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
        p=a[3]-a[2];
        if(a[2]-a[1]==p&&a[1]-a[0]==p)
            c=1;
        else{
                for(i=0;i<4;i++){
        for(j=i+1;j<4;j++){
            for(k=0;k<4;k++){
                if(k!=i&&k!=j){
                    if(a[i]+a[j]>a[k]){
                            if(a[j]+a[k]>a[i]){
                                    if(a[i]+a[k]>a[j])
                        c=1;
                        break;}}
                    else if(a[i]+a[j]==a[k]){
                        c=2;
                        break;}
                }
                if(c>0)
                    break;
            }
             if(c>0)
                    break;
        }
         if(c>0)
                    break;
    }
        }
    if(c==1)
        printf("TRIANGLE\n");
    else if(c==2)
        printf("SEGMENT\n");
    else
        printf("IMPOSSIBLE\n");

    return 0;
}

#include<stdio.h>

int main()
{  int a[4];
   int sum = 0;
   for  (int i=0;i<4;i++){
       scanf("%d", &a[i]);
       sum+=a[i];
   }
   int temp;
   temp = sum;
   int bol=0;
   int bol1=0;
   int seg = 0;
   for (int i=0;i<4;i++){
       temp=temp-a[i];
        for (int j=0;j<4;j++){
         if (a[i]!= a[j]){

             temp=temp-a[j];

             if (a[j]<temp) {
                 bol++;
                 }

             else if (a[j]==temp) {

                 bol1=1;

             }
            temp=temp+a[j];
         }

        }
        temp=temp+a[i];
        if(bol==3) {printf("TRIANGLE");break;};
        bol=0;

}
if (bol1==1 && bol!=3) {printf("SEGMENT");};
if ( bol1==bol) printf("IMPOSSIBLE");
}

#include<stdio.h>
int main(void)
{
	int length[4];
	unsigned int i=0,j=0,min=0,sum=0;
	for(;i<4;i++)
	scanf("%d",&length[i]);
    for(i=0;i<4;i++)
	{
	  for(j=0;j<4;j++)
	  {
      if(length[j]<length[i])
	  length[i]=length[j];
	  }
	}
	if(length[0]+length[1]>length[3]||length[0]+length[1]>length[2]||length[1]+length[2]>length[3])
	  printf("TRIANGLE");
	else
	  if(length[0]+length[1]==length[3]||length[0]+length[1]==length[2]||length[1]+length[2]==length[3])
	    printf("SEGMENT");
	  else
	  printf("IMPOSSIBLE");
	return 0;
}

#include<stdio.h>
#include<math.h>
#include<string.h>
long long a1[4][2]= {0},a2[4][2]= {0},b[3]= {0},flag;
long long sss1(long long x,long long y,long long z) {
	if(abs(x-y)>=z)return 0;
	if(abs(x-z)>=y)return 0;
	if(abs(y-z)>=x)return 0;
	return 1;
}
long long sss2(long long x,long long y,long long z) {
	if(abs(x-y)>z)return 0;
	if(abs(x-z)>y)return 0;
	if(abs(y-z)>x)return 0;
	return 1;
}
void dfs1(long long step) {
	if(step==3) {

		if(sss1(b[0],b[1],b[2]))flag=1;
		return;
	}
	long long i;
	for(i=0; i<4; i++) {
		if(a1[i][1])continue;
		b[step]=a1[i][0];
		a1[i][1]=1;
		dfs1(step+1);
		a1[i][1]=0;
		if(flag)return;
	}
	return;
}
void dfs2(long long step) {
	if(step==3) {
		printf("%lld %lld %lld\n",b[0],b[1],b[2]);
		if(sss2(b[0],b[1],b[2]))flag=1;
		return;
	}
	long long i;
	for(i=0; i<4; i++) {
		if(a2[i][1])continue;
		b[step]=a2[i][0];
		a2[i][1]=1;
		dfs2(step+1);
		a2[i][1]=0;
		if(flag)return;
	}
	return;
}
int main() {
	while(scanf("%lld%lld%lld%lld",&a1[0][0],&a1[1][0],&a1[2][0],&a1[3][0])!=EOF) {
		for(long long i=0; i<4; i++)
			a2[i][0]=a1[i][0];
		flag=0;
		dfs1(0);
		if(flag)printf("TRIANGLE\n");
		else {
			memset(b,0,sizeof(b));
			flag=0;
			dfs2(0);
			if(flag)printf("SEGMENT\n");
			else printf("IMPOSSIBLE\n");
		}
		memset(a1,0,sizeof(a1));
		memset(b,0,sizeof(b));
		memset(a2,0,sizeof(a2));
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int ara[4];
    for(int i=0;i<4;i++)
        scanf("%d",&ara[i]);
    for(int i=1;i<3;i++)
    {
        for(int j=0;j<3-i;j++)
            if(ara[j]>=ara[j+1])
        {
            int temp=ara[j+1];
            ara[j+1]=ara[j];
            ara[j]=temp;

        }}
if(ara[3]>=ara[0]+ara[1]+ara[2])
    printf("IMPOSSIBLE");
else {
    if((ara[0]+ara[1]>ara[2])||(ara[0]+ara[1]>ara[3])||(ara[1]+ara[2]>ara[3])||(ara[0]+ara[2]>ara[3]))
    printf("TRIANGLE");
    else printf("SEGMENT");
}

    return 0;
}

#include<process.h>
#include <stdio.h>

int main ()
{
    int num[5];
    int i, j, a, n=4;
    for (i = 0; i < n; ++i)
    scanf("%d", &num[i]);
    for (i = 0; i < n; ++i)
    {for (j = i + 1; j < n; ++j)
        {if (num[i] < num[j])
            {a = num[i];num[i] = num[j];num[j] = a;}}}
     if(num[0]>num[1]+num[2] || num[0]>(num[1]+num[3]) || num[1]>num[2]+num[3] || num[0]>num[2]+num[3]){
        printf("TRIANGLE");
        exit(0);
     }
     else if(num[0]==(num[1]+num[2]) || num[0]==(num[1]+num[3]) || num[1]==(num[2]+num[3]) || num[0]==(num[2]+num[3])  ){
        printf("SEGMENT");
        exit(0);
     }
     else{
        printf("IMPOSSIBLE");
        exit(0);}
     return 0;}

#include<stdio.h>

int main()
{
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if((a+b>c && a+c>b && b+c>a) || (a+b>d && a+d>b && b+d>a) || (b+c>d && b+d>c && c+d>b))
    {
        printf("TRIANGLE");
    }
    else if(a+b==c || a+b==d || a+c==b || a+c==d || a+d==b || a+d==c || b+c==a || b+c==d || b+d==a || b+d==c || c+d==a || c+d==b)
    {
        printf("SEGMENT");
    }
    else
    {
        printf("IMPOSSIBLE");
    }

    return 0;
}

#include <stdio.h>
int t = 0;
int s = 0;
int m[4];
void test(int a, int b, int c) {
	a = m[a];
	b = m[b];
	c = m[c];

	if (a + b > c && b+c > a && c+a > b)
		t = 1;
	else if (a+ b == c || b+c == a || c+a ==b)
		s = 1;
}
int main(void) {
	for (int i = 0; i < 4; i++)
		scanf("%d", m+i);
	test(0, 1, 2);
	test(1, 2, 3);
	test(2, 3, 1);
	test(3, 1, 0);
	if (t)
		printf("TRIANGLE\n");
	else if (s)
		printf("SEGMENT\n");
	else
		printf("IMPOSSIBLE\n");

	return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if((b+c>d&&c+d>b&&d+b>c)||
       (a+b>c&&a+c>b&&b+c>a)||
       (a+c>d&&c+d>a&&d+a>c)||
       (a+b>d&&b+d>a&&d+a>b))
        printf("TRIANGLE");
    else if(a+b+c>d&&a+b+d>c&&b+c+d>a&&a+c+d>b)
        printf("SEGMENT");
    else printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
    return  *(int *)a - *(int *)b;
}
int main()
{
    int a[4];
    int i;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
    qsort(a,4,sizeof(int),cmp);
    if(a[0]+a[1]>a[2]||a[0]+a[1]>a[3]||a[0]+a[2]>a[3]||a[1]+a[2]>a[3])
        printf("TRIANGLE");
    else if(a[0]+a[1]+a[2]>a[3])
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
    return 0;
}

#include<ctype.h>
#include<limits.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define TEST1(x, y, z) (x + y > z && abs(x - y) < z)
#define TEST2(x, y, z) (x + y == z || x + z == y || y + z == x)
int main(void)
{
    int a, b, c, d;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    if(TEST1(a, b, c) || TEST1(a, b, d) || TEST1(b, c, d))
        printf("TRIANGLE");
    else if(TEST2(a, b, c) || TEST2(a, b, d) || TEST2(b, c, d))
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");

    return 0;
}

#include<stdio.h>

int main(void){
  int seg[4],i,max=0,min=101,con=0;
  for(i=0;i<4;i++){
    scanf("%d",&seg[i]);
    if(seg[i]>max) max=seg[i];
    if(seg[i]<min) min=seg[i];
  }
  //printf("max:%d,min:%d\n",max,min);
  for(i=0;i<4;i++){
    if(seg[i]<max) con+=seg[i];
    else con-=seg[i];
  }
  //printf("con:%d\n",con);
  if(con<=0){
    puts("IMPOSSIBLE");
  }else{
    con-=min;
    //printf("con=%d\n",con);
    if(con>0) puts("TRIANGLE");
    else puts("SEGMENT");
  }
  return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
	int a[4],x,t=0;
	for(int i=0;i<4;i++)
	{
	scanf("%d",&a[i]);
    }
    for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
    for(int o=0;o<4;o++)
    {
    	if(t==0)
    	if(a[i]!=a[j]&&a[j]!=a[o]&&a[i]!=a[o])
    	{
    		if(a[i]<=a[j]+a[o]&&a[i]>=abs(a[j]-a[o]))
    		{
			    t=1;
    			printf("TRIANGLE");
    			break;
			}
			else if(a[i]>=a[j]+a[o]&&a[i]<=abs(a[j]-a[o]))
    		{
    			t=1;
    			printf("SEGMENT");
    			break;
			}
			else
			{
				t=1;
				printf("IMPOSSIBLE");
				break;
			}
		}
	}
return 0;
}

#include<stdio.h>

int stick[4]={0};
int check=0;
int tri=0;

int max(int x,int y,int z){
	return (x>y?x:y) > z ? (x>y?x:y):z;
}

int main(){

	//输入
	for(int i=0;i<4;i++){
		scanf("%d",&stick[i]);
	}

	for(int i=0;i<4;i++){
		for(int j=i+1;j<4;j++){
			for(int k=j+1;k<4;k++){
				int C=stick[i]+stick[j]+stick[k];
				int maxn=max(stick[i],stick[j],stick[k]);
				int rest = C-maxn;
				if(rest>maxn) tri = 1;
				else if(rest == maxn) check = 1;
				else check = 0;
			}
		}
	}

	if(tri == 1) printf("TRIANGLE");
	else if(tri!=1 && check == 1) printf("SEGMENT");
	else if(check = 0) printf("IMPOSSIBLE");

	return 0;
}

#include<stdio.h>
int main()
{
    int a[4],i,j,dif1,dif2,temp;

    for(i=0;i<4;i++)
    {
        scanf("%d",&a[i]);
    }

    for(i=0;i<3;i++)
    {
        for(j=i+1;j<4;j++)
        {
            if(a[i]>a[j])
            {
                temp=a[j];
                a[j]=a[i];
                a[i]=temp;
            }
        }
    }
    dif1=a[1]-a[0];
    dif2=a[3]-a[2];

    if(dif1<dif2)
    {
        if(a[0]+a[1]>a[2]) printf("TRIANGLE");
        else if(a[0]+a[1]==a[2]) printf("SEGMENT");
        else  printf("IMPOSSIBLE");
    }
    if(dif1>=dif2)
    {
        if(a[1]+a[2]>a[3]) printf("TRIANGLE");
        else if(a[1]+a[2]==a[3]) printf("SEGMENT");
        else  printf("IMPOSSIBLE");
    }

    return 0;

}

#include<stdio.h>
int a[5],b[5],book[5],n,flag=0,i,j;
void dfs(int step)
{
    if(step==4)
    {
        if(b[1]+b[2]>b[3]&&b[1]+b[3]>b[2]&&b[2]+b[3]>b[1])
            flag=1;
        else if(b[1]==b[2]||b[1]==b[3]||b[2]==b[3])
            flag=2;
        else
            flag=3;
        return ;
    }
    for(i=1;i<=4;i++)
    {
        if(book[i]==0)
        {
            b[step]=a[i];
            book[i]=1;
            dfs(step+1);
            if(flag==1||flag==2)
                break;
            book[i]=0;
        }
    }
    return ;
}
int main()
{
    for(i=1; i<=4; i++)
    {
        scanf("%d",&a[i]);
    }
    dfs(1);
    if(flag==1)
        printf("TRIANGLE");
    if(flag==2)
        printf("SEGMENT");
    if(flag==3)
        printf("IMPOSSIBLE");
    printf("\n");
}

#include<stdio.h>
int main(void)
{
    int i,j,k,flag=0;
    int a[5];
    for(i=0;i<4;i++) scanf("%d",&a[i]);

    for(i=0;i<4;i++)
        for(j=0;j<4;j++)
        for(k=0;i!=j && j!=k && i!=k && k<4;k++)
    {
        if(a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j])
        {
            printf("Triangle\n");
            printf("%d %d %d\n",a[i],a[j],a[k]);
            return 0;
        }
        if((a[i]+a[j])==a[k]|| a[j]+a[k]==a[i] || a[i]+a[k]==a[j]) flag=1;
    }

    if(flag==1) printf("Segment\n");
    else printf("Impossible\n");
    return 0;

}

#include <stdio.h>
int x, y, z, t, min;
int main()
{
    scanf("%d %d %d %d",&x,&y,&z,&t);
    int arr[] = { x, y, z, t };
    for (int j = 0; j < 4; j++) {
        for (int i = 0; i < 4; i++) {
            if(arr[i] >= arr[i + 1]) {
                min = arr[i + 1];
                arr[i + 1] = arr[i];
                arr[i] = min;
            }
        }
    }
    if (arr[0] + arr[1] < arr[2] && arr[1] + arr[2] < arr[3]) {
        printf("IMPOSSIBLE");
    }
    if ((arr[0] + arr[1] == arr[2] && arr[1] + arr[2] < arr[3]) || (arr[1] + arr[2] == arr[3] && arr[0] + arr[1] < arr[2])) {
        printf("SEGMENT");
    }
    if (arr[0] + arr[1] > arr[2] || arr[0] + arr[2] > arr[3] || arr[1] + arr[2] > arr[3]) {
        printf("TRIANGLE");
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmp(const int *a, const int *b)
{
    return *(int*)a-*(int*)b;
}

int tri(int x, int y, int z)
{
    if((2*(x+y+z))>(x+y+z))
        return 1;
    return 0;
}

int seg(int x, int y, int z)
{
    if(x+y==z)
        return 1;
    return 0;
}
int main()
{
    int i,a[4]={0},flagt=0,flags=0,flagi=0;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
    qsort(a,4,sizeof(int),cmp);
    /*for(i=0;i<4;i++)
        printf("%d ",a[i]);*/
    if(tri(a[0],a[1],a[2]) || tri(a[0],a[1],a[3]) || tri(a[0],a[2],a[3]) || tri(a[1],a[2],a[3]))
        flagt=1;

    else
    {
        if(seg(a[0],a[1],a[2]) || seg(a[0],a[1],a[3]) || seg(a[0],a[2],a[3]) || seg(a[1],a[2],a[3]))
            flags=1;

        else
            flagi=1;
    }
    if(flagt)
        printf("TRIANGLE\n");
    else if(flags)
        printf("SEGMENT\n");
    else
        printf("IMPOSSIBLE\n");
    return 0;
}

#include <stdio.h>
#include <math.h>

/**
 *
 * @param a
 * @param b
 * @param c
 * @return -1: nemozne, 0: segment, 1: trojuholnik
 */
int trojuholnik(int a, int b, int c) {
    if (b > c) {
        int tmp = b;
        b = c;
        c = tmp;
    }
    if (a > c) {
        int tmp = a;
        a = c;
        c = tmp;
    }
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    /*printf("%d %d %d", a, b, c);*/

    if (a+b < c) {
        return -1;
    } else if (a+b == c) {
        return 0;
    } else {
        return 1;
    }
}

int main(int argc, char* argv[]) {
    int d1,d2,d3,d4, tmp;
    int result;
    printf("Zadaj dlzky stran\n");
    result = scanf("%d %d %d %d", &d1, &d2, &d3, &d4);
    if (result != 4) {
        printf("Nespravny vstup\n");
        while (getchar() != '\n') {}
        main(argc, argv);
        return 0;
    }
    if (d1 < 0) d1 = -d1;
    if (d2 < 0) d2 = -d2;
    if (d3 < 0) d3 = -d3;
    if (d4 < 0) d4 = -d4;
    /*printf("%d %d %d %d", d1, d2, d3, d4);*/
    result = -1;
    tmp = trojuholnik(d1, d2, d3);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d1, d2, d4);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d2, d3, d4);
    if (tmp > result) result = tmp;
    tmp = trojuholnik(d1, d3, d4);
    if (tmp > result) result = tmp;
    if (result == 1) {
        printf("TROJUHELNIK\n");
    } else if (result == 0) {
        printf("SEGMENT\n");
    } else {
        printf("NEMOZNE\n");
    }
    return 0;
}

#include <stdio.h>
int trgl(int a,int b,int c);
void res(int a);
int main(){
    int a, b, c, d,x,y=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    x=trgl(a,b,c);
    if (x>c)
        c=x;
    x=trgl(a,c,d);
    if (x>c)
        c=x;
    x=trgl(a,b,d);
    if (x>c)
        c=x;
    x=trgl(b,c,d);
    if (x>c)
        c=x;
    res(c);
}
int trgl(int a,int b,int c){
    int y;
    if (a+b>c && b+c>a && c+a>b)
        y=3;
    else if (a+b==c || b+c==a || a+b==c)
        y=2;
    else
        y=1;

    return y;
}
void res(int a){
    if (a==3)
        printf("TRIANGLE");
    else if (a==2)
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
}

#include <stdio.h>

int check(int a, int b, int c)
{
	int ok1 = 0; int ok2 = 0; int ok3 = 0;
	if (a + b > c)
		ok1 = 1;
	if (b + c > a)
		ok2 = 1;
	if (a + c > b)
		ok3 = 1;

	return ok1 && ok2 && ok3;
}

int check_deg(int a, int b, int c)
{
	if (a + b == c)
		return 1;
	if (b + c == a)
		return 1;
	if (a + c == b)
		return 1;

	return 0;
}

int main(void)
{
	int a; int b; int c; int d;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	if (check(a, b, c) || check(a, b, d) || check(b, c, d)) {
		printf("TRIANGLE\n");
	} else if (check_deg(a, b, c) || check_deg(a, b, d) || check_deg(b, c, d)) {
		printf("SEGMENT\n");
	} else {
		printf("IMPOSSIBLE\n");
	}

	return 0;
}

#include<stdio.h>
int main()
{
    int j,a[4],temp=0,i,d;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);

    for(i=0;i<3;i++)
    {
        for(j=0;j<4;j++)
        {
            if(j!=i && j!=i+1)
            {
                if(a[i]+a[i+1]>a[j] && a[i]+a[j]>a[i+1] && a[i+1]+a[j]>a[i])
                {
                    temp=0;break;
                }
                else temp=1;
            }
        }
        if(temp==0)
            break;
    }
    if(temp==0)
    printf("TRIANGLE");

    else if (temp==1)
    {
        for(i=0;i<3;i++)
        {
            for(j=0;j<4;j++)
            {
                if(j!=i && j!=i+1)
                {
                    if(a[i]+a[i+1]==a[j])
                    {
                        temp=0;break;
                    }
                    else temp=1;
                }
            }
            if(temp==0)
                break;
        }
        if(temp==0)
            printf("SEGMENT");
        else
            printf("IMPOSSIBLE");
    }
}

#include <stdio.h>

int main() {
    int number[4];
    int i, j, a;
    scanf("%d %d %d %d", &number[0], &number[1], &number[2], &number[3]);

    for (i = 0; i < 4; ++i) {
            for (j = i + 1; j < 4; ++j) {
                if (number[i] > number[j]) {
                    a =  number[i];
                    number[i] = number[j];
                    number[j] = a;
            }
        }
    }
    int temp;
    if ((number[0] < number[1]+number[2] && number[1] < number[0]+number[2] && number[2] < number[0]+number[1]) || (number[0] < number[1]+number[4] && number[1] < number[0]+number[4] && number[4] < number[0]+number[1]) || (number[0] < number[4]+number[2] && number[4] < number[0]+number[2] && number[2] < number[0]+number[4]) || (number[4] < number[1]+number[2] && number[1] < number[4]+number[2] && number[2] < number[4]+number[1])) {
        printf("TRIANGLE\n");
        return 0;
    } else if ((number[0] == number[1]+number[2]|| number[1] == number[0]+number[2]|| number[2]== number[0]+number[1]) || (number[0] == number[1]+number[3] || number[1] == number[0]+number[3] || number[3] == number[0]+number[1]) || (number[0] == number[3]+number[2]|| number[3] == number[0]+number[2]|| number[2]== number[0]+number[3]) || (number[3] == number[1]+number[2]|| number[1] == number[3]+number[2]|| number[2]== number[3]+number[1])) {
         temp = 1;
    }

    if (temp) {
        printf("SEGMENT\n");
    } else {
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b)
{
    return  *(int *)a - *(int *)b;
}
int main()
{
    int a[4];
    int i;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);
    qsort(a,4,sizeof(int),cmp);
    if(a[0]+a[1]>a[2]||a[0]+a[1]>a[3]||a[0]+a[2]>a[3]||a[1]+a[2]>a[3])
        printf("TRIANGLE");
    else if(a[0]+a[1]+a[2]>a[3])
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>
int main()
{
int a,b,c,d;
scanf("%d%d%d",&a,&b,&c,&d);
if((a+b)>c && (c+b)>a && (a+c)>b){printf("TRIANGLE");return 0;}
if((d+b)>c && (c+b)>d && (d+c)>b){printf("TRIANGLE");return 0;}
if((a+d)>c && (c+d)>a && (a+c)>d){printf("TRIANGLE");return 0;}
if((a+b)>d && (d+b)>a && (a+d)>b){printf("TRIANGLE");return 0;}
if((a+b)==c || (c+b)==a || (a+c)==b){printf("SEGMENT");return 0;}
if((d+b)==c || (c+b)==d || (d+c)==b){printf("SEGMENT");return 0;}
if((a+d)==c || (c+d)==a || (a+c)==d){printf("SEGMENT");return 0;}
if((a+b)==d || (d+b)==a || (a+d)==b){printf("SEGMENT");return 0;}
printf("IMPOSSIIBLE");
return 0;
}

#include<stdio.h>
#include<stdlib.h>
int compare(const void *,const void *);
#define ll long long int
int compare(const void *a,const void *b)
{
  ll *num1=(ll*)a;
  ll *num2=(ll*)b;
  if((*num1)<(*num2))
    return -1;
  else
    return 1;
}
int main()
{
  ll a[4],i;
  for(i=0;i<4;i++)
    scanf("%lld",&a[i]);
  qsort(a,4,sizeof(ll),&compare);
  if(a[0]+a[1]>a[2] || a[1]+a[2]>a[3] || a[0]+a[2]>a[3])
    printf("TRIANGLE\n");
  else if(a[0]+a[1]==a[2] || a[1]+a[2]==a[3] || a[0]+a[2]==a[3])
    printf("SEGMENT\n");
  else
    printf("IMPOSSIBLE\n");
  return 0;
}

#include<stdio.h>
int a[5],b[5],book[5],n,flag=0,flag2=0,i,j;
void dfs(int step)
{
    if(step==4)
    {
        if(b[1]+b[2]>b[3]&&b[1]+b[3]>b[2]&&b[2]+b[3]>b[1])
            {
                flag=1;flag2=1;
                return ;
            }
        if(b[1]==b[2]||b[1]==b[3]||b[2]==b[3])
            {
                flag=2;
                return ;
            }
        return ;
    }
    for(i=1;i<=4;i++)
    {
        if(book[i]==0)
        {
            b[step]=a[i];
            book[i]=1;
            dfs(step+1);
            book[i]=0;
        }
    }
    return ;
}
int main()
{
    for(i=1; i<=4; i++)
    {
        scanf("%d",&a[i]);
    }
    dfs(1);
    if(flag==1&&flag2==1)
        printf("TRIANGLE");
    if(flag==2)
        printf("SEGMENT");
    if(flag==0)
        printf("IMPOSSIBLE");
    printf("\n");
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    int A,B,C;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a+b>=c && a+c>=b && b+c>=a)
    {   A=a;
        B=b;
        C=c;
        if(A==B||B==C){printf("SEGMENT\n"); return 0;}
        else {printf("TRIANGLE\n"); return 0;}
    }
    if(a+b>=d && a+d>=b && b+d>=a)
    {
        A=a;
        B=b;
        C=d;
        if(A==B||B==C){printf("SEGMENT\n"); return 0;}
        else {printf("TRIANGLE\n"); return 0;}
    }
    if(a+c>=d && a+d>=c && c+d>=a)
    {
        A=a;
        B=c;
        C=d;
        if(A==B||B==C){printf("SEGMENT\n"); return 0;}
        else {printf("TRIANGLE\n"); return 0;}
    }
    if(b+c>=d && b+d>=c && c+d>=b)
    {
        A=b;
        B=c;
        C=d;
        if(A==B||B==C){printf("SEGMENT\n"); return 0;}
        else {printf("TRIANGLE\n"); return 0;}
    }
    printf("IMPOSSIBLE\n");

    return 0;
}

#include <stdio.h>
int t = 0;
int s = 0;
int m[4];
void test(int a, int b, int c) {
	a = m[a];
	b = m[b];
	c = m[c];

	if (a + b > c && b+c > a && c+a > b)
		t = 1;
	else if ((a+ b) == c || (b+c) == a || (c+a) ==b)
		s = 1;
}
int main(void) {
	for (int i = 0; i < 4; i++)
		scanf("%d", m+i);
	test(0, 1, 2);
	test(1, 2, 3);
	test(2, 3, 1);
	test(3, 1, 0);
	if (t)
		printf("TRIANGLE\n");
	else if (s)
		printf("SEGMENT\n");
	else
		printf("IMPOSSIBLE\n");

	return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a[4],i,j,k,d;
	for(i=0;i<4;i++)
		scanf("%d",&a[i]);
	for(i=0;i<4;i++)
	{
		for(j=0;j<4;j++){
			if(i==j)
				continue;
			for(k=0;k<4;k++)
			{
				if(i==k || j==k)
					continue;
				if(a[i]<a[j]+a[k] && a[i]>abs(a[j]-a[k]))
				{
					d=1;
					goto c;
				}
				else if(a[i]==a[j]+a[k])
					d=2;

			}
		}

	}
c:
	if(d==1)
		printf("TRIANGLE");
	else if(d==2)
		printf("SEGMENT");
	else
		printf("IMPOSSIBLE");
	return 0;

}

#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    if((a+b>c&&a+c>b&&b+c>a)||(a+d>c&&a+c>d&&d+c>a)||(d+b>c&&d+c>b&&b+c>d)||(a+b>d&&a+d>b&&b+d>a))
        printf("TRIANGLE");
    else if((a+b==c||a+c==b||b+c==d)||(a+d==c||a+c==d||d+c==a)||(d+b==c||d+c==b||b+c==d)||(a+b==d||a+d==b||b+d==a))
        printf("SEGMENT");
    else
        printf("IMPOSSIBLE");
    return 0;
}

#include<stdio.h>

int main()
{
	int i,stcks[4],sum,j,f1=0,f2=0;
	scanf("%d %d %d %d",&stcks[0],&stcks[1],&stcks[2],&stcks[3]);
	sum = stcks[0]+stcks[1]+stcks[2]+stcks[3];

	for (i=0;i<4;i++)
	{
		int ssum = sum - stcks[i];
		for (j=0;j<4;j++)
		{
			if (j==i)
				continue;
			int psum = ssum - stcks[j];
			if (psum>stcks[j])
			{
				f1++;
			}
			else if(psum==stcks[j])
				f2++;
		}
		if (f1==3)
			f1=1;
		else
			f1=0;
	}
	if (f1)
	{
		printf("TRIANGLE");
		return 0;
	}
	if (f2)
	{
		printf("SEGMENT");
		return 0;
	}
	printf("IMPOSSIBLE");
	return 0;
}

#include<stdio.h>

int main()
{
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    if((a+b>c && a+c>b && b+c>a) || (a+b>d && a+d>b && b+d>a) || (b+c>d && b+d>c && c+d>b))
    {
        printf("TRIANGLE");
    }
    else if(a+b==c || a+b==d || a+c==b || a+c==d || a+d==b || a+d==c || b+c==a || b+c==d || b+d==a || b+d==c || c+d==a || c+d==b)
    {
        printf("SEGMENT");
    }
    else
    {
        printf("IMPOSSIBLE");
    }

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main() {
 int d[4],i,a,b,c,yac=0;
 for(i=0; i<4; i++)
 scanf("%d",&d[i]);

 for(i=0; i<4; i++)
 {
     for(b=0; b<4; b++)
     {
         if(i==b) continue;
         for(c=0; c<4; c++)
         {
             if(i==b || b==c || i==c)
             continue;
             if(d[i]<d[b]+d[c] && d[i]>abs(d[b]-d[c])) { yac=1; goto o; }
             else if(d[i]==d[c]+d[b]) { yac=2; goto o; }
         }
     }
 }
 o:
 if(yac==1)
 printf("TRIANGLE\n");
 else if(yac==2)
 printf("SEGMENT");
 else
 printf("IMPOSSIBLE");

    return 0;
}

#include <stdio.h>

int triangle(int a, int b, int c) {
	return a + b > c && b + c > a && c + a > b;
}

int segment(int a, int b, int c, int d) {
	return a + b == c || a + b == d;
}

int main() {
	int a, b, c, d;

	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (triangle(a, b, c)
			|| triangle(b, c, d)
			|| triangle(c, d, a)
			|| triangle(d, a, b))
		printf("TRIANGLE\n");
	else if (segment(a, b, c, d)
			|| segment(b, c, a, d)
			|| segment(c, d, a, b)
			|| segment(a, d, b, c))
		printf("SEGMENT\n");
	else
		printf("IMPOSSIBLE\n");
	return 0;
}

#include <stdio.h>

int main (void) {
    int atto[4],i,j,k,l=0,m=0,n=0;

    scanf("%d %d %d %d", &atto[0],&atto[1],&atto[2],&atto[3]);

    // bubble sort
    for(i=0; i<4; i++) {
        for(j=i+1; j<4; j++) {
            if(atto[i]<atto[j]) {
                k=atto[i];
                atto[i]=atto[j];
                atto[j]=k;
            }
        }
    }

    for(i=0; i<2; i++) {
        if(atto[i] < atto[i+1]+atto[i+2]) l++;
        else if(atto[i] == atto[i+1]+atto[i+2]) m++;
        else n++;
    }

    if(l>0) printf("TRIANGLE");
    else printf("IMPOSSIBLE");

    return 0;
}

#include<stdio.h>

int main()
{
    int  i, aray[5], j, temp;
    scanf("%d %d %d %d", &aray[0],&aray[1], &aray[2], &aray[3] );
    for(i=1;i<=3;i++){
        j=i;
        while(j>0 && aray[j]<aray[j-1]){
            temp=aray[j];
            aray[j]=aray[j-1];
            aray[j-1]=temp;
            j--;
        }
    }
    if(aray[1]+aray[2]>aray[3]){
        printf("TRIANGLE");
        return 0;
    }
    if(aray[0]+aray[1]==aray[2] || aray[0]+aray[1]==aray[3] || aray[1]+aray[2]==aray[3]){
        printf("SEGMENT");
        return 0;
    }
    printf("IMPOSSIBLE");
    return 0;
}

#include <stdio.h>

int main() {
    int number[4];
    int i, j, a;
    scanf("%d %d %d %d", &number[0], &number[1], &number[2], &number[3]);

    for (i = 0; i < 4; ++i) {
            for (j = i + 1; j < 4; ++j) {
                if (number[i] > number[j]) {
                    a =  number[i];
                    number[i] = number[j];
                    number[j] = a;
            }
        }
    }
    int temp;
    if ((number[0] < number[1]+number[2] && number[1] < number[0]+number[2] && number[2] < number[0]+number[1]) || (number[0] < number[1]+number[4] && number[1] < number[0]+number[4] && number[4] < number[0]+number[1]) || (number[0] < number[4]+number[2] && number[4] < number[0]+number[2] && number[2] < number[0]+number[4]) || (number[4] < number[1]+number[2] && number[1] < number[4]+number[2] && number[2] < number[4]+number[1])) {
        printf("TRIANGLE\n");
        return 0;
    } else if ((number[0] == number[1]+number[2]|| number[1] == number[0]+number[2]|| number[2]== number[0]+number[1]) || (number[0] == number[1]+number[3] || number[1] == number[0]+number[3] || number[3] == number[0]+number[1]) || (number[0] == number[3]+number[2]|| number[3] == number[0]+number[2]|| number[2]== number[0]+number[3]) || (number[3] == number[1]+number[2]|| number[1] == number[3]+number[2]|| number[2]== number[3]+number[1])) {
         temp = 1;
    }

    if (temp) {
        printf("SEGMENT\n");
    } else {
        printf("IMPOSSIBLE\n");//
    }
    return 0;
}

#include <stdio.h>
#include <string.h>

int f(int a, int b, int c) {
	if (a + b < c || b + c < a || a + c < b) {
		return 0;
	} else if (a + b == c || b + c == a || a + c == b) {
		return 1;
	} else {
		return 2;
	}
}

int main() {
	char input[10000];
	scanf("%[^\n]%*c", input);
	char* pch = strtok(input, " ");

	int a = atoi(pch);
	pch = strtok(NULL, " ");
	int b = atoi(pch);
	pch = strtok(NULL, " ");
	int c = atoi(pch);
	pch = strtok(NULL, " ");
	int d = atoi(pch);
	pch = strtok(NULL, " ");

	int d1 = f(a, b, c);
	int d2 = f(a, b, d);
	int d3 = f(a, c, d);
	int d4 = f(b, c, d);

	if (d1 | d2 | d3 | d4 == 2) {
		printf("%s\n", "TRIANGLE");
	} else if (d1 | d2 | d3 | d4 == 1) {
		printf("%s\n", "SEGMENT");
	} else {
		printf("%s\n", "IMPOSSIBLE");
	}
}

#include<stdio.h>
#include<stdlib.h>
int main() {
 int d[4],i,a,b,c,yac;
 for(i=0; i<4; i++)
 scanf("%d",&d[i]);

 for(i=0; i<4; i++)
 {
     for(b=0; b<4; b++)
     {
         if(i==b) continue;
         for(c=0; c<4; c++)
         {
             if(i==b || b==c || i==b)
             continue;
             if(d[i]<d[b]+d[c] && d[i]>abs(d[b]-d[c])) { yac=1; goto o; }
             else if(d[i]==d[c]+d[b]) { yac=2; goto o; }
         }
     }
 }
 o:
 if(yac==1)
 printf("TRIANGLE\n");
 else if(yac==2)
 printf("SEGMENT");
 else
 printf("IMPOSSIBLE");

    return 0;
}

//
//  main.c
//  triangle
//
//  Created by Anton Titkov on 26/10/2016.
//  Copyright © 2016 Anton Titkov. All rights reserved.
//

#include <stdio.h>

typedef struct Triangle {
    int sideA;
    int sideB;
    int sideC;
} Triangle;

int checkInput(int testVal) {
    if ((testVal < 1)||(testVal>100)) {
        return 0;
    }
    return 1;
}

typedef enum TestResult {
    RET_TRIANGLE,
    RET_SEGMENT,
    RET_IMPOSSIBLE,
} TestResult;

TestResult testTriangle(Triangle testSubject) {

    if (((testSubject.sideA + testSubject.sideB) > testSubject.sideC) && ((testSubject.sideB + testSubject.sideC) > testSubject.sideA)&& ((testSubject.sideA + testSubject.sideC) > testSubject.sideB))
        return RET_TRIANGLE;

    if ((testSubject.sideA + testSubject.sideB) == testSubject.sideC)
        return RET_SEGMENT;

    return RET_IMPOSSIBLE;
}

int main(int argc, const char * argv[]) {

    int sticks = 4;

    int a,b,c,d;
    int testValues[sticks];

    if ((scanf("%d %d %d %d",&a,&b,&c,&d)!=sticks)||!checkInput(a)||!checkInput(b)||!checkInput(c)||!checkInput(d)) {
        printf("IMPOSSIBLE\n");
    }

    testValues[0] = a;
    testValues[1] = b;
    testValues[2] = c;
    testValues[3] = d;

    int isTriangle = 0;
    int isSegment = 0;

    for (int i = 0; i < sticks; i++) {
        int value1 = testValues[i];
        for (int k = i+1; k<sticks; k++) {
            int value2 = testValues[k];
            for (int j = k+1; j<sticks; j++) {
            int value3 = testValues[j];

                int tmp;

                if (value1>value3) {
                    tmp = value1;
                    value1 = value3;
                    value3 = tmp;
                }

                if (value1>value2) {
                    tmp = value1;
                    value1 = value2;
                    value2 = tmp;
                }

                if (value2>value3) {
                    tmp = value2;
                    value2 = value3;
                    value3 = tmp;
                }

                 printf("combo %i %i %i\n",value1,value2,value3);

                Triangle test = (Triangle){value1,value2,value3};

                TestResult result = testTriangle(test);

                switch (result) {
                    case RET_SEGMENT:
                        isSegment = 1;
                        break;
                    case RET_TRIANGLE:
                        isTriangle = 1;
                        break;
                    default:
                        break;
                }
            }
        }
    }

    if (isTriangle) {
        printf("TRIANGLE\n");
        return 0;
    }

    if (isSegment) {
        printf("SEGMENT\n");
        return 0;
    }

    printf("IMPOSSIBLE\n");

    return 0;
}

#include<stdio.h>
int main()
{
    int a[4],i,t;
    for(i=0;i<4;i++)
        scanf("%d",&a[i]);

    for(i=0;i<4;i++){
        if(a[0]<a[i]){
                t=a[0];
                a[0]=a[i];
                a[i]=t;
        }
    }
    if(a[0]<a[1]+a[2])
        printf("TRIANGLE\n");
    else if(a[0]<a[1]+a[3])
         printf("TRIANGLE\n");
    else if(a[0]<a[2]+a[3])
         printf("TRIANGLE\n");
        else if(a[0]==a[1]&&a[1]==a[2])
            printf("TRIANGLE\n");
        else if(a[0]==a[1]&&a[1]==a[3])
            printf("TRIANGLE\n");
            else if(a[0]==a[2]&&a[2]==a[3])
            printf("TRIANGLE\n");
            else if(a[1]==a[2]&&a[2]==a[3])
            printf("TRIANGLE\n");

    else if(a[0]+a[1]==a[2])
        printf("SEGMENT\n");
    else if(a[0]+a[1]==a[3])
        printf("SEGMENT\n");
        else if(a[0]+a[2]==a[1])
        printf("SEGMENT\n");
        else if(a[0]+a[2]==a[3])
        printf("SEGMENT\n");
        else if(a[0]+a[3]==a[1])
        printf("SEGMENT\n");
        else if(a[0]+a[3]==a[2])
        printf("SEGMENT\n");
        else if(a[1]+a[2]==a[0])
        printf("SEGMENT\n");
        else if(a[1]+a[2]==a[3])
         printf("SEGMENT\n");
         else if(a[1]+a[3]==a[0])
        printf("SEGMENT\n");
    else if(a[1]+a[3]==a[2])
        printf("SEGMENT\n");
        else if(a[2]+a[3]==a[0])
        printf("SEGMENT\n");
    else if(a[2]+a[3]==a[1])
        printf("SEGMENT\n");

    else
        printf("IMPOSSIBLE\n");

    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main() {
 int d[4],i,a,b,c,yac;
 for(i=0; i<4; i++)
 scanf("%d",&d[i]);

 for(i=0; i<4; i++)
 {
     for(b=0; b<4; b++)
     {
         if(i==b) continue;
         for(c=0; c<4; c++)
         {
             if(i==b || b==c || i==b)
             continue;
             if(d[i]<d[b]+d[c] && d[i]<abs(d[b]-d[c])) { yac=1; goto o; }
             else if(d[i]==d[c]+d[b]) { yac=2; goto o; }
         }
     }
 }
 o:
 if(yac==1)
 printf("TRIANGLE\n");
 else if(yac==2)
 printf("SEGMENT");
 else
 printf("IMPOSSIBLE");

    return 0;
}