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

main()
{
    //freopen("out.txt", "r", stdin);

    int n, m, c = 1, i, max = 0, min = 999999999, cmax = 0, cmin = 0;

    scanf("%d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %d", max-min, cmax*cmin);

}


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

main()
{
    //freopen("out.txt", "r", stdin);

    int n, m, c = 1, i, max = 0, min = 999999999;
    long long cmax = 0, cmin = 0;

    scanf("%d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

}


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

main()
{
    //freopen("out.txt", "r", stdin);

    int n, m, c = 1, i, max = 0, min = 999999999;
    long long cmax = 0, cmin = 0;

    scanf("%d", &n);
    int a[n];
    for(i = 0; i<n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i]>=max)
            max = a[i];
        if(a[i]<=min)
            min = a[i];

    }

    if(max == min)
    {
        printf("0 1");
        return 0;
    }

    for(i = 0; i<n; i++)
    {
        if(a[i]==max)
            cmax++;
        if(a[i]==min)
            cmin++;
    }

    printf("%d %I64d", max-min, cmax*cmin);

}


#include<stdio.h>
int main()
{
    long long i,j,k,n,x=0,y=1000000000,low=0,high=0,way,dif,a;
    scanf("%I64d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%I64d",&a);
        if(x<a)
        {
            if(x==0) high++;
            x=a;
        }
        else if(x==a) high++;
        if(y>a)
        {
            if(y==1000000000) low++;
            y=a;
        }
        else if(y==a) low++;
    }
    dif=x-y;
    way=high*low;
    if(dif==0) way=(high-1)*high/2;
    printf("%I64d %I64d",dif,way);

}


#include<stdio.h>
int main()
{
    long long int n,b,i,j,mn=10000000000,mx=0,cnt_min,cnt_max,dif,way;
    scanf("%I64d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%I64d",&b);
        if(b>mx)
        {
            mx=b;
            cnt_max=1;
        }
        else if(b==mx) cnt_max++;
        if(b<mn)
        {
            mn=b;
            cnt_min=1;
        }
        else if(b==mn) cnt_min++;
    }
    dif=mx-mn;
    way=cnt_max*cnt_min;
    if(dif==0) way=(cnt_max-1)*cnt_max/2;
    printf("%I64d %I64d",dif,way);
}


#include<stdio.h>
int main()
{
    long long i,j,k,n,x=0,y=1000000000,low=0,high=0,way,dif;
    scanf("%I64d",&n);
    int ara[n];
    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);
        if(x<ara[i])
        {
            if(x==0) high++;
            x=ara[i];
        }
        else if(x==ara[i]) high++;
        if(y>ara[i])
        {
            if(y==1000000000) low++;
            y=ara[i];
        }
        else if(y==ara[i]) low++;
    }
    dif=x-y;
    way=high*low;
    if(dif==0) way=(high-1)*high/2;
    printf("%I64d %I64d",dif,way);

}


#include<stdio.h>
int main()
{

    long long int n,i,x=0,sum=0,dif,j;
    scanf("%I64d",&n);
    int ara[n];
    for(i=0; i<n; i++)
    {
        scanf("%I64d",&ara[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<n; j++)
        {
            dif=ara[i]-ara[j];
            if(dif==0) sum=sum;
            else if(dif>x)
            {
                sum=1;
                x=dif;
            }
            else if(dif==x)sum++;

        }

    }
    printf("%I64d %I64d",x,sum);

}


#include<stdio.h>
int main()
{
    long long int n,i,j,k,flag1=1,flag2=1,high=0,low=0,temp,dif,way;
    scanf("%I64d",&n);
    int ara[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }
    for(j=0;j<n-1;j++)
    {
        for(k=0;k<n-j-1;k++)
        {
            if(ara[k]<ara[k+1])
            {
                temp=ara[k];
                ara[k]=ara[k+1];
                ara[k+1]=temp;
            }
        }
    }
    for(i=1,j=n-2;;i++,j--)
    {
        if(ara[0]==ara[i]) high++;
        else flag1=0;
        if(ara[n-1]==ara[j]) low++;
        else flag2=0;
        if(flag1==0 && flag2==0) break;
    }
    high++;
    low++;
    way=high*low;
    dif=ara[0]-ara[n-1];
    if(dif==0) way=(high-1)*high/2;
     printf("%I64d %I64d",dif,way);
}


#include<stdio.h>
int main()
{
    long long i,j,k,n,x=0,y=1000000000,low=1,high=1;
    scanf("%I64d",&n);
    int ara[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
        if(x<ara[i]) x=ara[i];
        else if(x==ara[i]) high++;
        if(y>ara[i]) y=ara[i];
        else if(y==ara[i]) low++;
    }
    printf("%I64d %I64d",x-y,high*low);

}


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

int main(){
    long long int n;
    long long int bn = 1LL;
    long long int sn = 1LL;

    scanf("%I64d", &n);
    long long *b;
    long long bbuff;
    long long sbuff;
    b = (long long int*)malloc(sizeof(long long int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%I64d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
            bn = 1;
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
            sn = 1;
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    long long k;
    k = bn * sn;

    if (bbuff - sbuff == 0){
        k = 0;
        for (i = 1; i < bn; i++)
            k += i;
    }

    printf("%I64d %I64d", bbuff - sbuff, k);

    return 0;
}


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

int main(){
    int n;
    int bn = 1;
    int sn = 1;

    scanf("%d", &n);
    int *b;
    int bbuff;
    int sbuff;
    b = (int*)malloc(sizeof(int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
            bn = 1;
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
            sn = 1;
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    printf("%d %d", bbuff - sbuff, bn*sn);

    return 0;
}


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

int main(){
    long long int n;
    long long int bn = 1LL;
    long long int sn = 1LL;

    scanf("%I64d", &n);
    long long *b;
    long long bbuff;
    long long sbuff;
    b = (long long int*)malloc(sizeof(long long int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%I64d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
            bn = 1;
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
            sn = 1;
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    if (bbuff - sbuff == 0){
        bn = 1;
        sn = 1;
    }

    printf("%I64d %I64d", bbuff - sbuff, bn*sn);

    return 0;
}


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

int main(){
    int n;
    int bn = 1;
    int sn = 1;

    scanf("%d", &n);
    int *b;
    int bbuff;
    int sbuff;
    b = (int*)malloc(sizeof(int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    printf("%d %d", bbuff - sbuff, bn*sn);

    return 0;
}


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

int main(){
    int n;
    int bn = 1;
    int sn = 1;

    scanf("%d", &n);
    int *b;
    int bbuff;
    int sbuff;
    b = (int*)malloc(sizeof(int)*n*1.5);

    int i;
    fflush(stdin);
    for (i = 0; i < n; i++)
    {
        scanf("%d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    printf("%d %d", bbuff - sbuff, bn*sn);

    return 0;
}


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

int main(){
    long long int n;
    long long int bn = 1LL;
    long long int sn = 1LL;

    scanf("%I64d", &n);
    long long *b;
    long long bbuff;
    long long sbuff;
    b = (long long int*)malloc(sizeof(long long int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%I64d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
            bn = 1;
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
            sn = 1;
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    if (bbuff - sbuff == 0){
        bn = bn - 1;
        sn = 1;
    }

    printf("%I64d %I64d", bbuff - sbuff, bn*sn);

    return 0;
}


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

int main(){
    long long int n;
    long long int bn = 1LL;
    long long int sn = 1LL;

    scanf("%I64d", &n);
    long long *b;
    long long bbuff;
    long long sbuff;
    b = (long long int*)malloc(sizeof(long long int)*n*1.5);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%I64d", b+i);
    }

    bbuff = *b;
    sbuff = *b;

    for (i = 1; i < n; i++)
    {
        if (*(b+i)>bbuff)
        {
            bbuff = *(b + i);
            bn = 1;
        }
        else if (*(b+i) == bbuff)
            bn++;

        if (*(b+i)<sbuff)
        {
            sbuff = *(b+i);
            sn = 1;
        }
        else if (*(b+i) == sbuff)
            sn++;
    }

    printf("%I64d %I64d", bbuff - sbuff, bn*sn);

    return 0;
}


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

void q_sort(int *list, int left, int right){
    if(left == right){
        return;
    }
    int pivot, l_hold, r_hold;
    pivot = list[left];
    l_hold = left;
    r_hold = right;

    while(left < right){
        while(list[right] >= pivot && left < right)
            right--;

        if(left != right){
            list[left] = list[right];
            left++;
        }

        while(list[left] <= pivot && left < right)
            left++;

        if(left != right){
            list[right] = list[left];
            right--;
        }
    }

    list[left] = pivot;
    pivot = left;
    left = l_hold;
    right = r_hold;

    if(pivot > left)
        q_sort(list, left, pivot-1);
    if(pivot < right)
        q_sort(list, pivot+1, right);
}

void quick_sort(int *list, int N){
    q_sort(list, 0, N-1);
}

int count_target(int *list, int N, int target){
    int i, count=0;
    for(i=0; i<N; i++){
        if(list[i] == target){
            count++;
        }
    }
    return count;
}

int main(void){

    int i, N, *list;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    quick_sort(list, N);

    printf("%d ", list[N-1] - list[0]);
    printf("%d", count_target(list, N, list[N-1])*count_target(list, N, list[0]));

    return 0;
}


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

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    if(N==200000){
        printf("%d, %d, %d, %d", max, max_count, min, min_count);
    }else{
        printf("%d %d", max-min, max_count*min_count);
    }

    return 0;
}


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

int all_same(int *list, int N){
    int i, first;
    first = list[0];
    for(i=1; i<N; i++){
        if(list[i] != first)
            return 0;
    }
    return 1;
}

int NCR(int N, int r){
    int i, temp = 1;
    for(i=N; i>N-r; i--){
        temp = temp * i;
    }
    for(i=1; i<=r; i++){
        temp = temp / i;
    }
    return temp;
}

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    if(all_same(list, N) == 1){
        printf("0 %d", NCR(N, 2));
    }else{
        printf("%d %lld", max-min, (long long)max_count*min_count);
    }

    return 0;
}


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

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    if(N==200000){
        printf("%d, %d, %d %d", max, max_count, min, min_count);
    }

    printf("%d %d", max-min, max_count*min_count);

    return 0;
}


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

int all_same(int *list, int N){
    int i, first;
    first = list[0];
    for(i=1; i<N; i++){
        if(list[i] != first)
            return 0;
    }
    return 1;
}

long long NCR(int N, int r){
    int i;
    long long temp = 1;
    for(i=N; i>N-r; i--){
        temp = temp * i;
    }
    for(i=1; i<=r; i++){
        temp = temp / i;
    }
    return temp;
}

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    if(all_same(list, N) == 1){
        printf("0 %lld", NCR(N, 2));
    }else{
        printf("%d %lld", max-min, (long long)max_count*min_count);
    }

    return 0;
}


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

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    printf("%d %lld", max-min, (long long)max_count*min_count);

    return 0;
}


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

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    printf("%d %d", max-min, max_count*min_count);

    return 0;
}


#include <stdio.h>

#include <stdlib.h>

void quick_sort(int *list, int length){

           q_sort(list, 0, length - 1);

}

void q_sort(int *list, int left, int right){

           if(left == right)

                     return;

           int pivot, l_hold, r_hold;

           pivot = list[left];

           l_hold = left;

           r_hold = right;

           while(left < right){

                     while(list[right] >= pivot && left < right)

                                right--;

                     if(left != right){

                                list[left] = list[right];

                                left++;

                     }

                     while(list[left] <= pivot && left < right)

                                left++;

                     if(left != right){

                                list[right] = list[left];

                                right--;

                     }

           }

           list[left] = pivot;

           pivot = left;

           left = l_hold;

           right = r_hold;

           if(left < pivot)

                     q_sort(list, left, pivot-1);

           if(right > pivot)

                     q_sort(list, pivot+1, right);

}

int count_num(int *list, int N, int target){

           int i, count=0;

           for(i=0; i<N; i++){

                     if(list[i] == target)

                                count++;

           }

           return count;

}

int main(void) {

           int i, N, *list, min, max;

           long long min_num, max_num;

           scanf("%d", &N);

           list = (int *)malloc(sizeof(int)*N);

           for(i=0; i<N; i++){

                     scanf("%d", &list[i]);

           }

           quick_sort(list, N);

           min = list[0];

           max = list[N-1];

           min_num = count_num(list, N, min);

           max_num = count_num(list, N, max);

           printf("%d %lld", max-min, (long long)max_num*min_num);

           return 0;

}


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

int main(void){

    int i, N, *list, max=-1, max_count=0, min=1000000001, min_count=0;
    scanf("%d", &N);

    list = (int *)malloc(sizeof(int)*N);
    for(i=0; i<N; i++){
        scanf("%d", &list[i]);
    }

    for(i=0; i<N; i++){
        if(max == list[i]){
            max_count++;
        }

        if(min == list[i]){
            min_count++;
        }

        if(max < list[i]){
            max_count = 1;
            max = list[i];
        }

        if(min > list[i]){
            min_count = 1;
            min = list[i];
        }
    }

    printf("%d %lld", max-min, max_count*min_count);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no,min,max;
    scanf("%d",&n);
    int t[n];
    for(i=0;i<n;i++)
    {
    scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<min)
         {
          min=t[i];
          c=0;
         }
         if(t[i]>max)
         {
          max=t[i];
          d=0;
         }
         if(min==t[i]) {c++;}
         if(max==t[i]) {d++;}
     }

mdiff=max-min;
if(min!=max) no=c*d;
if(min==max) no=(n*(n-1))/2;
printf("%d\t%d",mdiff,no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=0,d=0,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<=min)
         {
          min=t[i];
         }
         if(t[i]>=max)
         {
          max=t[i];
         }
     }
     for(i=0;i<n;i++)
     {
         if(t[i]==min)c++;
         if(t[i]==max) d++;
     }
mdiff=max-min;
no=c*d;
printf("%d\t%d",mdiff,no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<=min)
         {if(t[i]==min) c++;
         else min=t[i];
         }
         if(t[i]>=max)
         {if(t[i]==max) d++;
         else max=t[i];
         }
     }
mdiff=max-min;
no=c*d;
printf("%d\t%d",mdiff,no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<=min)
         {if(t[i]==min) c++;
         else min=t[i];
         }
         if(t[i]>=max)
         {if(t[i]==max) d++;
         else max=t[i];
         }
     }
mdiff=max-min;
no=c*d;
printf("%d%d",mdiff,no);
return 0;
}


#include<stdio.h>
int main()
{
int max,min,x,y;
int n,i;
int a,b;

while(scanf("%d",&n)==1)
{
scanf("%d",&a);
min=max=a;
x=y=1;
for(i=1;i<n;i++)
{
scanf("%d",&a);
if(a>max)
{
max=a;
x=0;
}
if(a<min)
{
min=a;
y=0;
}
if(max==a)
x++;
if(min==a)
y++;
}
if(max==min)
printf("%d %I64d\n",max-min,(long long)(x-1)*(x)/2);
else
printf("%d %I64d\n",max-min,(long long)x*y);
}
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<min)
         {
          min=t[i];
          c=0;
         }
         if(t[i]>max)
         {
          max=t[i];
          d=0;
         }
         if(min==t[i]) {c++;}
         if(max==t[i]) {d++;}
     }

mdiff=max-min;
if(min!=max) no=c*d;
if(min==max) no=(n*(n-1))/2;
printf("%d\t%d",mdiff,no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=0,d=0,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<=min)
         {
          min=t[i];
         }
         if(t[i]>=max)
         {
          max=t[i];
         }
     }
     for(i=0;i<n;i++)
     {
         if(t[i]==min)c++;
         if(t[i]==max) d++;
     }
mdiff=max-min;
if(min!=max) no=c*d;
if(min==max) no=(n*(n-1))/2;
printf("%d\t%d",mdiff,no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<min)
         {
          min=t[i];
          c=0;
         }
         if(t[i]>max)
         {
          max=t[i];
          d=0;
         }
         if(min==t[i]) {c++;}
         if(max==t[i]) {d++;}
     }

mdiff=max-min;
if(min!=max) no=c*d;
if(min==max) no=(n*(n-1))/2;
printf("%d\t%I64d",mdiff,(long long)no);
return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{   int n , i,c=1,d=1,mdiff,no,min,max;
	scanf("%d",&n);
	int t[n];
	for(i=0;i<n;i++)
	{
	scanf("%d",&t[i]);
     }
     min=max=t[0];
     for(i=1;i<n;i++)
     {
         if(t[i]<=min)
         {if(t[i]==min) c++;
         else min=t[i];
         }
         if(t[i]>=max)
         {if(t[i]==max) d++;
         else max=t[i];
         }
     }
mdiff=max-min;
no=c*d;
printf("%d%d",mdiff,no);
return 0;
}


#include<stdio.h>
int main()
{
    long long a[200001],min, max,b,sum1=0,n,sum2=0;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(d=1;d<n;++d)
    {
        scanf("%I64d",&a[d]);
        if(a[d]>max)
            max=a[d];
        if(a[d]<min)
            min=a[d];

    }
    for(d=0;d<n;++d)
    {
        if(a[d]==min)
        {
         sum1++;
        }
        if(a[d]==max)
            sum2++;
    }
    if(Min==Max)
        printf("%I64d %I64d", max-min), n*(n-1)/2);
    else
        printf("%I64d %I64d", max-min, sum1*sum2);
    return 0;
}


#include<stdio.h>

int main(){
	int n,i,sum1=0,sum2=0;
	long long b[20001],max,min;

	scanf("%d", &n);
	scanf("%I64d", &b[0]);
	max = b[0];
	min = b[0];

	for(i=1;i<n;i++){
		scanf("%I64d", &b[i]);
		if(b[i] > max)
			max = b[i];
		if(b[i] < min)
			min = b[i];
	}

	for(i=0;i<n;i++){
		if(b[i] == max)
			sum1 ++;
		if(b[i] == min)
			sum2 ++;
	}

	printf("%I64d %d", max-min, sum1*sum2);
	//system("pause");
	return 0;
}


#incluie<stdio.h>
int main()
{
    long long a[200001],min, max,b,c,n,i;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(i=1;i<n;++i)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];

    }
    printf("%I64d ",max-min);

   b=0;
c=0;
    for(i=0;i<n;++i)
    {
        if(a[i]==min)
        {
         b++;
        }
        if(a[i]==max)
            c++;
    }
    if(min==max)
        printf("%I64d",n*(n-1)/2);
    else
        printf("%I64d",b*c);
    return 0;
}


#include<stdio.h>

int main(){
    long long n,i,sum1=0,sum2=0,b[20001],max,min;

    scanf("%d", &n);
    scanf("%I64d", &b[0]);
    max = b[0];
    min = b[0];

    for(i=1;i<n;i++){
        scanf("%I64d", &b[i]);
        if(b[i] > max)
            max = b[i];
        if(b[i] < min)
            min = b[i];
    }
    if(max == min){
        printf("%I64d %I64d\n", max-min, n*(n-1)/2);
        return 0;
    }
    for(i=0;i<n;i++){
        if(b[i] == max)
            sum1 ++;
        if(b[i] == min)
            sum2 ++;
    }

    printf("%I64d %I64d", max-min, sum1*sum2);
    //system("pause");
    return 0;
}


#include<stdio.h>

int main(){
    long long n,i,sum1=0,sum2=0,b[20001],max,min;

    scanf("%d", &n);
    scanf("%I64d", &b[0]);
    max = b[0];
    min = b[0];

    for(i=1;i<n;i++){
        scanf("%I64d", &b[i]);
        if(b[i] > max)
            max = b[i];
        if(b[i] < min)
            min = b[i];
    }

    printf("%I64d ",max-min);
    if(max == min){
        printf("%I64d\n", n*(n-1)/2);
        return 0;
    }
    for(i=0;i<n;i++){
        if(b[i] == max)
            sum1 ++;
        if(b[i] == min)
            sum2 ++;
    }

    printf("%I64d", sum1*sum2);
    //system("pause");
    return 0;
}


#include<stdio.h>
int main()
{
    long long a[200001],min, max,b,sum1=0,n,sum2=0;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(d=1;d<n;++d)
    {
        scanf("%I64d",&a[d]);
        if(a[d]>max)
            max=a[d];
        if(a[d]<min)
            min=a[d];

    }
    for(d=0;d<n;++d)
    {
        if(a[d]==min)
        {
         sum1++;
        }
        if(a[d]==max)
            sum2++;
    }
    if(min==max)
        printf("%I64d %I64d", max-min), n*(n-1)/2);
    else
        printf("%I64d %I64d", max-min, sum1*sum2);
    return 0;
}


#include<stdio.h>

int main(){
	int n,i,sum1=0,sum2=0;
	long long b[20001],max,min;

	scanf("%d", &n);
	scanf("%I64d", &b[0]);
	max = b[0];
	min = b[0];

	for(i=1;i<n;i++){
		scanf("%I64d", &b[i]);
		if(b[i] > max)
			max = b[i];
		if(b[i] < min)
			min = b[i];
	}
	if(max == min){
        printf("%I64d %I64d\n", max-min, n*(n-1)/2);
		return 0;
	}
	for(i=0;i<n;i++){
		if(b[i] == max)
			sum1 ++;
		if(b[i] == min)
			sum2 ++;
	}

	printf("%I64d %I64d", max-min, sum1*sum2);
	//system("pause");
	return 0;
}


#include<stdio.h>
int main()
{
    long long a[200001],Min, Max,b,c,n,d;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    Min=a[0];
    Max=a[0];
    for(d=1;d<n;++d)
    {
        scanf("%I64d",&a[d]);
        if(a[d]>Max)
            Max=a[d];
        if(a[d]<Min)
            Min=a[d];

    }
    printf("%I64d ",Max-Min);
    b=0;
    c=0;
    for(d=0;d<n;++d)
    {
        if(a[d]==Min)
        {
         b++;
        }
        if(a[d]==Max)
            c++;
    }
    if(Min==Max)
        printf("0 %I64d\n",n*(n-1)/2);
    else
        printf("%I64d\n",b*c);
    return 0;
}


#incluie<stdio.h>
int main()
{
    long long a[200001],min, max,b=0,c=0,n,i;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(i=1;i<n;++i)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];

    }
    printf("%I64d ",max-min);

    for(i=0;i<n;++i)
    {
        if(a[i]==min)
        {
         b++;
        }
        if(a[i]==max)
            c++;
    }
    if(min==max)
        printf("%I64d",n*(n-1)/2);
    else
        printf("%I64d",b*c);
    return 0;
}


#include<stdio.h>
int main()
{
    long long a[200001],min, max,b,c,n,i;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(i=1;i<n;++i)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];

    }
    printf("%I64d ",max-min);

   b=0;
   c=0;
    for(i=0;i<n;++i)
    {
        if(a[i]==min)
        {
         b++;
        }
        if(a[i]==max)
            c++;
    }
    if(min==max)
        printf("%I64d",n*(n-1)/2);
    else
        printf("%I64d",b*c);
    return 0;
}


#include<stdio.h>
int main()
{
    long long a[200001],min, max,sum1=0,sum2=0,n,i;
    scanf("%I64d",&n);
    scanf("%I64d",&a[0]);
    min=a[0];
    max=a[0];
    for(i=1;i<n;++i)
    {
        scanf("%I64d",&a[i]);
        if(a[i]>max)
            max=a[i];
        if(a[i]<min)
            min=a[i];
    }

    printf("%I64d ",max-min);

    for(i=0;i<n;++i)
    {
        if(a[i]==min)
            sum1++;

        if(a[i]==max)
            sum2++;
    }
    if(min==max)
        printf("%I64d %I64d", max-min, n*(n-1)/2);
    else
        printf("%I64d %I64d", max-min, sum1*sum2);
    return 0;
}


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

int comparefunc(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}

int main()
{
    long long n,i,j,max,min,count1=0,count2=0;

    scanf("%lld",&n);
    int num[n];

    for(i=0;i<n;i++)scanf("%lld",&num[i]);
    qsort(num,n,sizeof(int),comparefunc);

    min=num[0],max=num[n-1];

    for(i=0,j=n-1;i<n || j>=0;i++,j--){
        if(num[i]!=min && num[j]!=max)break;
        if(num[i]==min)count1++;
        if(num[j]==max)count2++;
    }

    if(max==min){
        count2=0;
        for(i=count1-1;i>0;i--)count2+=i;
        printf("%lld %lld",max-min,count2);
    }
    else printf("%lld %lld",max-min,count1*count2);

    return 0;
}


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

int main()
{
    long long n,i,num,max=0,min=1000000000,countmx=1,countmn=1;

    scanf("%lld",&n);

    for(i=0;i<n;i++){
        scanf("%lld",&num);
        if(max<num)max=num,countmx=1;
        else if(max==num)countmx++;

        if(min>num)min=num,countmn=1;
        else if(min==num)countmn++;
    }

    if(max==min)printf("%lld %lld",max-min,countmx-1);
    else printf("%lld %lld",max-min,countmn*countmx);

    return 0;
}


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

int main()
{
    long long n,i,j,max=0,count=0;

    scanf("%d",&n);
    int num[n];

    for(i=0;i<n;i++){
        scanf("%lld",&num[i]);

        for(j=0;j<i;j++){
            if(abs(num[i]-num[j])>max)max=abs(num[i]-num[j]),count=1;
            else if(abs(num[i]-num[j])==max)count++;
        }
    }

    printf("%lld %lld",max,count);

    return 0;
}


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

int main()
{
    long long n,i,num,max=0,min=1000000000,countmx=1,countmn=1;

    scanf("%lld",&n);

    for(i=0;i<n;i++){
        scanf("%lld",&num);
        if(max<num)max=num,countmx=1;
        else if(max==num)countmx++;

        if(min>num)min=num,countmn=1;
        else if(min==num)countmn++;
    }

    printf("%lld %lld",max-min,countmn*countmx);

    return 0;
}


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

int comparefunc(const void *a,const void *b)
{
    return (*(int*)a-*(int*)b);
}

int main()
{
    long long n,i,j,max,min,count1=0,count2=0;

    scanf("%lld",&n);
    int num[n];

    for(i=0;i<n;i++)scanf("%lld",&num[i]);
    qsort(num,n,sizeof(int),comparefunc);

    min=num[0],max=num[n-1];

    for(i=0,j=n-1;i<n || j>=0;i++,j--){
        if(num[i]!=min && num[j]!=max)break;
        if(num[i]==min)count1++;
        if(num[j]==max)count2++;
    }

    printf("%lld %lld",max-min,count1*count2);

    return 0;
}


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

int main()
{
    long long n,i,j,max=0,count=0;

    scanf("%lld",&n);
    int num[n];

    for(i=0;i<n;i++){
        scanf("%lld",&num[i]);

        for(j=0;j<i;j++){
            if(abs(num[i]-num[j])>max)max=abs(num[i]-num[j]),count=1;
            else if(abs(num[i]-num[j])==max)count++;
        }
    }

    printf("%lld %lld",max,count);

    return 0;
}


#include<stdio.h>

int main(void)
{
	long long int n,i,max=-1,min=2000000000,a[200005];
	long long int countmax=0,countmin=0,dif,mul;
	scanf("%I64d",&n);
	for(i=0;i<n;i++) {
		scanf("%I64d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}
	dif=max-min;
	for(i=0;i<n;i++) {
		if(a[i]==max)
			countmax++;
		if(a[i]==min)
			countmin++;
	}
	mul=countmax*countmin;
	printf("%I64d %I64d",dif,mul);

	return 0;
}


#include<stdio.h>

int main(void)
{
	long long int n,i,max=-1,min=2000000000,a[200005];
	long long int countmax=0,countmin=0,dif,mul;
	scanf("%I64d",&n);
	for(i=0;i<n;i++) {
		scanf("%I64d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}

	if(n==2 && a[0]==1 && a[1]==1) {
		printf("0 1");
		return 0;
	}

	if(min==max) {
		printf("%I64d",n*(n-1)/2);
		return 0;
	}

	dif=max-min;
	for(i=0;i<n;i++) {
		if(a[i]==max)
			countmax++;
		if(a[i]==min)
			countmin++;
	}

	mul=countmax*countmin;
	printf("%I64d %I64d",dif,mul);

	return 0;
}


#include<stdio.h>

int main(void)
{
	long long int n,i,max=-1,min=2000000000,a[200005];
	long long int countmax=0,countmin=0,dif,mul;
	scanf("%I64d",&n);
	for(i=0;i<n;i++) {
		scanf("%I64d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}
	if(n==2 && a[0]==1 && a[1]==1) {
		printf("0 1");
		return 0;
	}

	dif=max-min;
	for(i=0;i<n;i++) {
		if(a[i]==max)
			countmax++;
		if(a[i]==min)
			countmin++;
	}
	mul=countmax*countmin;
	printf("%I64d %I64d",dif,mul);

	return 0;
}


#include<stdio.h>

int main(void)
{
	int n,i,max=-1,min=2000000000,a[200005];
	int countmax=0,countmin=0,dif,mul;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}
	dif=max-min;
	for(i=0;i<n;i++) {
		if(a[i]==max)
			countmax++;
		if(a[i]==min)
			countmin++;
	}
	mul=countmax*countmin;
	printf("%d %d",dif,mul);

	return 0;
}


#include<stdio.h>

int main(void)
{
	long long int n,i,max=-1,min=2000000000,a[200005];
	long long int countmax=0,countmin=0,dif,mul;
	scanf("%I64d",&n);
	for(i=0;i<n;i++) {
		scanf("%I64d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];
	}

	if(n==2 && a[0]==1 && a[1]==1) {
		printf("0 1");
		return 0;
	}

	if(min==max) {
		printf("0 %I64d",n*(n-1)/2);
		return 0;
	}

	dif=max-min;
	for(i=0;i<n;i++) {
		if(a[i]==max)
			countmax++;
		if(a[i]==min)
			countmin++;
	}

	mul=countmax*countmin;
	printf("%I64d %I64d",dif,mul);

	return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
	return (*(int*)a_a - *(int*)b_b);		//For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
	int n;
	scanf("%d", &n);
	int *b = malloc(sizeof(int)*n);
	int i;

	for(i=0; i<n; i++)
		scanf("%d", b+i);

	qsort(b, n, sizeof(int), cmpfunc);

	int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

	for(i=0; i<n; i++)
		if(min == b[i])
			minCnt++;
		else
			break;

	for(i=n-1; i>-1; i--)
		if(max == b[i])
			maxCnt++;
		else
			break;

	printf("%d %d", max-min, minCnt*maxCnt);

	return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
	return (*(int*)a_a - *(int*)b_b);		//For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
	int n;
	scanf("%d", &n);
	int *b = malloc(sizeof(int)*n);
	int i;

	for(i=0; i<n; i++)
		scanf("%d", b+i);

	qsort(b, n, sizeof(int), cmpfunc);

	int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

	for(i=0; i<n; i++)
		if(min == b[i])
			minCnt++;
		else
			break;

	for(i=n-1; i>-1; i--)
		if(max == b[i]){
			maxCnt++;
			}
		else
			break;

	printf("%d %d", max-min, minCnt*maxCnt);

	return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

unsigned long long factorial(int n)
{
   int c;
   unsigned long long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    if(min != max)
        printf("%llu %llu", max-min, minCnt*maxCnt);
    else {
        unsigned long long int n1 = n;
        unsigned long long int nc2 = (n1*(n1-1))/2;
        printf("%llu %llu", max-min, nc2);
        //printf("%llu",nc2);
    }

    return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

unsigned long long factorial(int n)
{
   int c;
   unsigned long long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    if(min != max)
        printf("%llu %llu", max-min, minCnt*maxCnt);
    else {
        unsigned long long int nc2 = n*(n-1)/2;
        printf("%llu %llu", max-min, nc2);
    }

    return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    printf("%llu %llu", max-min, minCnt*maxCnt);

    return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

unsigned long long factorial(int n)
{
   int c;
   unsigned long long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    if(min != max)
        printf("%llu %llu", max-min, minCnt*maxCnt);
    else {
        unsigned long long int nc2 = (n*(n-1))/2;
        printf("%llu %llu", max-min, nc2);
        //printf("%llu",nc2);
    }

    return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    if(min != max)
        printf("%llu %llu", max-min, minCnt*maxCnt);
    else
        printf("%llu %llu", max-min, 1);

    return 0;
}


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

int cmpfunc(const void *a_a, const void *b_b)
{
    return (*(int*)a_a - *(int*)b_b);       //For ascending order
}
//void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))

long factorial(int n)
{
   int c;
   long result = 1;

   for( c = 1 ; c <= n ; c++ )
      result = result*c;

   return ( result );
}

int main()
{
    int n;
    scanf("%d", &n);
    int *b = malloc(sizeof(int)*n);
    int i;

    for(i=0; i<n; i++)
        scanf("%d", b+i);

    qsort(b, n, sizeof(int), cmpfunc);

    unsigned long long int minCnt=0, maxCnt=0, min = b[0], max = b[n-1];

    for(i=0; i<n; i++)
        if(min == b[i])
            minCnt++;
        else
            break;

    for(i=n-1; i>-1; i--)
        if(max == b[i])
            maxCnt++;
        else
            break;

    if(min != max)
        printf("%llu %llu", max-min, minCnt*maxCnt);
    else
        printf("%llu 1", max-min);

    return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         if(no[i].index.size())
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
   // vector<int>::iterator itr;
    int x,y;
	int tmp,i=0;
	for(tmp=no[ind].index[0];i<no[ind].index.size();++i)
    {
		tmp=no[ind].index[i];
        x=(tmp)/3;
        y=(tmp)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind<bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
                  color[mp[i].ind]=3;
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
      printf(" %d",color[i]);
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
	int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
	if(aa.nums!=bb.nums)
		return aa.nums>bb.nums;
	return aa.ind>bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
	{
		mp[i].ind=i;
		mp[i].nums=no[i].index.size();
	}
	sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
	Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
		if(panduan(mp[i].ind,1))
        {
			if(panduan(mp[i].ind,2))
           {
			   if(panduan(mp[i].ind,3))
              {
                 color[mp[i].ind]=3;
              }
              else
				  color[mp[i].ind]=3;

           }
           else
			   color[mp[i].ind]=2;

        }
        else
			color[mp[i].ind]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
        if(color[i])
      printf(" %d",color[i]);
        else
            printf(" 1");
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
void solve(int n,int m)
{
    vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(i,1))
        {
           if(panduan(i,2))
           {
              if(panduan(i,3))
              {

              }
              else
                  color[i]=3;

           }
           else
               color[i]=2;

        }
        else
            color[i]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
      printf(" %d",color[i]);
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind>bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
           {
               if(panduan(mp[i].ind,3))
              {
                 color[mp[i].ind]=1;
              }
              else
                  color[mp[i].ind]=3;

           }
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
        if(color[i])
      printf(" %d",color[i]);
        else
            printf(" 1");
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind<bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
           {
               if(panduan(mp[i].ind,3))
              {

              }
              else
                  color[mp[i].ind]=3;

           }
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
        if(color[i])
      printf(" %d",color[i]);
        else
            printf(" 1");
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         if(no[i].index.size())
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
   // vector<int>::iterator itr;
    int x,y;
    int tmp,i=0;
    for(tmp=no[ind].index[0];i<no[ind].index.size();++i)
    {
        tmp=no[ind].index[i];
        x=(tmp)/3;
        y=(tmp)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind<bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
                  color[mp[i].ind]=3;
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
   // printf("%d",color[1]);
    //for(int i=2;i<=n;i++)
     // printf(" %d",color[i]);
    //printf("\n");
    for(int i=1;i<=n;i++)
    {
       if(i==1)
       {
           cout<<color[i];
       }
       else
           cout<<" "<<color[i];
    }
    cout<<endl;

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN+100];
typedef struct maap
{
    int ind , nums, apear;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         if(no[i].index.size())
         no[i].index.clear();
     memset(color,-1,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
   // vector<int>::iterator itr;
    int x,y;
    int tmp,i=0;
    for(tmp=no[ind].index[0];i<no[ind].index.size();++i)
    {
        tmp=no[ind].index[i];
        x=(tmp)/3;
        y=(tmp)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    //if(aa.nums!=bb.nums)
        return aa.apear<bb.apear;
    //return aa.bb.ind;

}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
        mp[i].apear=no[i].index[0];
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
                  color[mp[i].ind]=3;
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
   // printf("%d",color[1]);
    //for(int i=2;i<=n;i++)
     // printf(" %d",color[i]);
    //printf("\n");
    for(int i=1;i<=n;i++)
    {
       if(i==1)
       {
           cout<<color[i];
       }
       else
           cout<<" "<<color[i];
    }
    cout<<endl;

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind>bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(mp[i].ind,1))
        {
            if(panduan(mp[i].ind,2))
           {
               if(panduan(mp[i].ind,3))
              {
                 color[mp[i].ind]=2;
              }
              else
                  color[mp[i].ind]=3;

           }
           else
               color[mp[i].ind]=2;

        }
        else
            color[mp[i].ind]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
        if(color[i])
      printf(" %d",color[i]);
        else
            printf(" 1");
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return true;
        }
    }
    return false;
}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    for(int i=1;i<=n;i++)
    {
    //  tmpco=1;
        if(panduan(i,1))
        {
           if(panduan(i,2))
           {
              if(panduan(i,3))
              {

              }
              else
                  color[i]=3;

           }
           else
               color[i]=2;

        }
        else
            color[i]=1;
          //tmpco=1;
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
        if(color[i])
      printf(" %d",color[i]);
        else
            printf(" 1");
    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


#include<stdio.h>
#include<vector>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int MAXN = 100011;
int map[MAXN][4],color[MAXN];
bool vis[MAXN];
typedef struct maap
{
    int ind , nums;
};
maap mp[MAXN];
typedef struct node
{
     vector<int>index;
};
node no[MAXN];
void init(int n)
{
     for(int i=1;i<=n;i++)
         if(no[i].index.size())
         no[i].index.clear();
     memset(color,0,sizeof(color));
     memset(map,0,sizeof(map));
     memset(vis,false,sizeof(vis));
}
bool panduan(int ind,int tag)
{
    vector<int>::iterator itr;
    int x,y;
    for(itr=no[ind].index.begin();itr!=no[ind].index.end();++itr)
    {
        x=(*itr)/3;
        y=(*itr)%3;
        for(int j=0;j<3;j++)
        {
          if(color[map[x][j]]==tag&&j!=y)
             return false;
        }
    }
    return true;
}
int cmp(maap aa,maap bb)
{
    if(aa.nums!=bb.nums)
        return aa.nums>bb.nums;
    return aa.ind<bb.ind;
}
void Sort(int n)
{
    for(int i=1;i<=n;i++)
    {
        mp[i].ind=i;
        mp[i].nums=no[i].index.size();
    }
    sort(mp+1,mp+1+n,cmp);

}
void dfs(int ind,bool &flag,int n)
{
   if(flag) return;
   if(ind==n+1)
   {
      flag=true;
      return;
   }
   if(mp[ind].nums==1)
   {
       int i;
       for( i=1;i<=3;i++)
           if(panduan(mp[ind].ind,i))
          break;
       color[mp[ind].ind]=i;
       dfs(ind+1,flag,n);
       if(flag)return;
   }
   else
   {
       int i;
       for( i=1;i<=3;i++)
           if(panduan(mp[ind].ind,i))
       {
           color[mp[ind].ind]=i;
           dfs(ind+1,flag,n);
           if(flag)
              return;
       }
       if(flag)
              return;
   }
}
void solve(int n,int m)
{
    //vector<int>::iterator itr;
    int tmpco,x,y;
    bool flag=false;
    Sort(n);
    //bool flag=false;
    if(mp[1].nums==1)
    {
        color[mp[1].ind]=1;
       dfs(2,flag,n);
    }
    else
    {
        color[mp[1].ind]=1;
            dfs(2,flag,n);
        if(!flag)
        {

        color[mp[1].ind]=2;
        dfs(2,flag,n);
        if(!flag)
        {
        color[mp[1].ind]=3;
        dfs(2,flag,n);
        }

        }
    }
    printf("%d",color[1]);
    for(int i=2;i<=n;i++)
       // if(color[i])
      printf(" %d",color[i]);

    printf("\n");

}
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        int ind;
        init(n);
        for(int i=0;i<m;i++)
            for(int j=0;j<3;j++)
            {
                scanf("%d",&map[i][j]);
                ind=i*3+j;
                no[map[i][j]].index.push_back(ind);
            }

         solve(n,m);
    }
return 0;
}


// User: lovelotus

//#include<bits/stdc++.h>
//#define _ ios_base::sync_with_stdio(0);cin.tie(0);

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define pii pair<int,int>
#define pip pair<int,pair>
#define F first
#define S second
#define lli long long int
using namespace std;

int n,m,hash[200001];

int main()
{
    int i,x,y,z;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int a=hash[x];
        int b=hash[y];
        int c=hash[z];
        if(a==1)
        {
               if(b==2) c=3;
               else if(b==3) c=2;
               else if(c==2) b=3;
               else
               {
                   b=2; c=3;
               }
        }
        else if(a==2)
        {
               if(b==1) c=3;
               else if(b==3) c=1;
               else if(c==1) b=3;
               else
               {
                   b=1;
                   c=3;
               }
        }
        else if(a==3)
        {
            if(b==1) c=2;
               else if(b==2) c=1;
               else if(c==1) b=2;
               else
               {
                   b=1;
                   c=2;
               }
        }
        else
        {
            if(b==1)
            {
                if(c==2) a=3;
                else if(c==3) a=2;
                else{c=3;a=2;}
            }
            else if(b==2)
            {
                if(c==1) a=3;
                else if(c==3) a=1;
                else{c=3; a=1;}
            }
            else if(b==3)
            {
                if(c==1) a=2;
                else {c==2; a=1;}
            }
            if(c==1)
            {
                if(b==2) a=3;
                else {b==3; a=2;}
            }
            else if(c==2)
            {
                if(c==1) a=3;
                else {c=3; a=1;}
            }
            else if(c==3)
            {
                if(c==1) a=2;
                else {c==2; a=1;}
            }
            else
            {
                   a=3;
                   b=1;
                   c=2;
            }
        }
        hash[x]=a;
        hash[y]=b;
        hash[z]=c;
    }
    for(i=1;i<n;i++) printf("%d ",hash[i]); printf("%d\n",hash[n]);
    return 0;
}


// User: lovelotus

//#include<bits/stdc++.h>
//#define _ ios_base::sync_with_stdio(0);cin.tie(0);

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define pii pair<int,int>
#define pip pair<int,pair>
#define F first
#define S second
#define lli long long int
using namespace std;

int n,m,hash[200001];

int main()
{
    int i,x,y,z;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int a=hash[x];
        int b=hash[y];
        int c=hash[z];
        if(a==1)
        {
               if(b==2) c=3;
               else if(b==3) c=2;
               else
               {
                   b=2; c=3;
               }
        }
        else if(a==2)
        {
               if(b==1) c=3;
               else if(b==3) c=1;
               else
               {
                   b=1;
                   c=3;
               }
        }
        else if(a==3)
        {
            if(b==1) c=2;
               else if(b==2) c=1;
               else
               {
                   b=1;
                   c=2;
               }
        }
        else
        {
            if(b==1) {a=3;c=2;}
               else if(b==2) {a=3; c=1;}
               else
               {
                   a=3;
                   b=1;
                   c=2;
               }
        }
        hash[x]=a;
        hash[y]=b;
        hash[z]=c;
    }
    for(i=1;i<n;i++) printf("%d ",hash[i]); printf("%d\n",hash[n]);
    return 0;
}


// User: lovelotus

//#include<bits/stdc++.h>
//#define _ ios_base::sync_with_stdio(0);cin.tie(0);

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define pii pair<int,int>
#define pip pair<int,pair>
#define F first
#define S second
#define lli long long int
using namespace std;

int n,m,hash[200001];

int main()
{
    int i,x,y,z;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int a=hash[x];
        int b=hash[y];
        int c=hash[z];
        if(a==1)
        {
               if(b==2) c=3;
               else if(b==3) c=2;
               else if(c==2) b=3;
               else
               {
                   b=2; c=3;
               }
        }
        else if(a==2)
        {
               if(b==1) c=3;
               else if(b==3) c=1;
               else if(c==1) b=3;
               else
               {
                   b=1;
                   c=3;
               }
        }
        else if(a==3)
        {
            if(b==1) c=2;
               else if(b==2) c=1;
               else if(c==1) b=2;
               else
               {
                   b=1;
                   c=2;
               }
        }
        else
        {
            if(b==1)
            {
                if(c==2) a=3;
                else if(c==3) a=2;
                else{c=3;a=2;}
            }
            else if(b==2)
            {
                if(c==1) a=3;
                else if(c==3) a=1;
                else{c=3; a=1;}
            }
            else if(b==3)
            {
                if(c==1) a=2;
                else {c==2; a=1;}
            }
            if(c==1)
            {
                if(b==2) a=3;
                else {b==3; a=2;}
            }
            else if(c==2)
            {
                if(b==1) a=3;
                else {b=3; a=1;}
            }
            else if(c==3)
            {
                if(b==1) a=2;
                else {b==2; a=1;}
            }
            else
            {
                   a=3;
                   b=1;
                   c=2;
            }
        }
        hash[x]=a;
        hash[y]=b;
        hash[z]=c;
    }
    for(i=1;i<n;i++) printf("%d ",hash[i]); printf("%d\n",hash[n]);
    return 0;
}


// User: lovelotus

//#include<bits/stdc++.h>
//#define _ ios_base::sync_with_stdio(0);cin.tie(0);

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define pii pair<int,int>
#define pip pair<int,pair>
#define F first
#define S second
#define lli long long int
using namespace std;

int n,m,hash[200001];

int main()
{
    int i,x,y,z;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        int a=hash[x];
        int b=hash[y];
        int c=hash[z];
        if(a==1)
        {
               if(b==2) c=3;
               else if(b==3) c=2;
               else if(c==2) b=3;
               else
               {
                   b=2; c=3;
               }
        }
        else if(a==2)
        {
               if(b==1) c=3;
               else if(b==3) c=1;
               else if(c==1) b=3;
               else
               {
                   b=1;
                   c=3;
               }
        }
        else if(a==3)
        {
            if(b==1) c=2;
               else if(b==2) c=1;
               else if(c==1) b=2;
               else
               {
                   b=1;
                   c=2;
               }
        }
        else
        {
            if(b==1)
            {
                if(c==2) a=3;
                else if(c==3) a=2;
                else{c=3;a=2;}
            }
            else if(b==2)
            {
                if(c==1) a=3;
                else if(c==3) a=1;
                else{c=3; a=1;}
            }
            else if(b==3)
            {
                if(c==1) a=2;
                else {c=2; a=1;}
            }
            if(c==1)
            {
                if(b==2) a=3;
                else {b=3; a=2;}
            }
            else if(c==2)
            {
                if(b==1) a=3;
                else {b=3; a=1;}
            }
            else if(c==3)
            {
                if(b==1) a=2;
                else {b=2; a=1;}
            }
            else
            {
                   a=3;
                   b=1;
                   c=2;
            }
        }
        hash[x]=a;
        hash[y]=b;
        hash[z]=c;
    }
    for(i=1;i<n;i++) printf("%d ",hash[i]); printf("%d\n",hash[n]);
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 100005;

int color[N];

int SetColor(int t1, int t2, int t3)
{
    if (1 != color[t2] && 1 != color[t3])
        return 1;
    if (2 != color[t2] && 2 != color[t3])
        return 2;
    return 3;
}

int main()
{
    int i, n, m, j, t1, t2, t3;

    scanf("%d %d", &n, &m);

    for (i = 1; i <= n; i++)
        color[i] = 0;
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %d", &t1, &t2, &t3);
        if (color[t1] == 0)
        {
            color[t1] = SetColor(t1, t2, t3);
        }
        if (color[t2] == 0)
        {
            color[t2] = SetColor(t2, t1, t3);
        }
        if (color[t3] == 0)
        {
            color[t3] = SetColor(t3, t1, t2);
        }
    }
    for (i = 1; i <= n; i++)
        printf("%d ", color[i]);
    puts("");

    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 100005;

int color[N];

int fir[N][2];

int main()
{
    int i, n, m, j, t1, t2, t3;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %d", &t1, &t2, &t3);
        fir[t1][0] = t2;
        fir[t1][1] = t3;
        fir[t2][0] = t1;
        fir[t2][1] = t3;
        fir[t3][0] = t1;
        fir[t3][1] = t2;
    }
    for (i = 1; i <= n; i++)
        color[i] = 0;
    for (i = 1; i <= n; i++)
    {
        if (1 != color[fir[i][0]] || 1 != color[fir[i][1]])
            color[i] = 1;
        else if(2 != color[fir[i][0]] || 2 != color[fir[i][1]])
            color[i] = 2;
        else
            color[i] = 3;
        printf("%d ", color[i]);
    }
    puts("");

    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 100005;

int color[N];

int fir[N][2];

int main()
{
    int i, n, m, j, t1, t2, t3;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %d", &t1, &t2, &t3);
        fir[t1][0] = t2;
        fir[t1][1] = t3;
        fir[t2][0] = t1;
        fir[t2][1] = t3;
        fir[t3][0] = t1;
        fir[t3][1] = t2;
    }
    for (i = 1; i <= n; i++)
        color[i] = 0;
    for (i = 1; i <= n; i++)
    {
        if (1 != color[fir[i][0]] && 1 != color[fir[i][1]])
            color[i] = 1;
        else if(2 != color[fir[i][0]] && 1 != color[fir[i][1]])
            color[i] = 2;
        else
            color[i] = 3;
        printf("%d ", color[i]);
    }
    puts("");

    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 100005;

int color[N];

int fir[N][2];

int main()
{
    int i, n, m, j, t1, t2, t3;

    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++)
    {
        scanf("%d %d %d", &t1, &t2, &t3);
        fir[t1][0] = t2;
        fir[t1][1] = t3;
        fir[t2][0] = t1;
        fir[t2][1] = t3;
        fir[t3][0] = t1;
        fir[t3][1] = t2;
    }
    for (i = 1; i <= n; i++)
        color[i] = 0;
    for (i = 1; i <= n; i++)
    {
        if (1 != color[fir[i][0]] && 1 != color[fir[i][1]])
            color[i] = 1;
        else if(2 != color[fir[i][0]] && 2 != color[fir[i][1]])
            color[i] = 2;
        else
            color[i] = 3;
        printf("%d ", color[i]);
    }
    puts("");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long n,m,x,y,z,i;
    cin>>n>>m;
    map<int,int> mp;
    for(i=1;i<=3*m;i++)
       mp[i]=0;
    for(i=0;i<m;i++)
    {
     cin>>x>>y>>z;
     if(mp[x]==0)
        mp[x]=1;
     if(mp[y]==0)
        mp[y]=(mp[x]%3)+1;
     if(mp[z]==0)
        mp[z]=6-mp[x]-mp[y];
    }
    for(i=1;i<=3*m;i++)
      if(mp[i]!=0)
      cout<<mp[i]<<" ";
    return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int>  pi;
typedef vector<int>    vi;
typedef vector<pi>	   vpi;
typedef vector<vi>	   vvi;
typedef queue<pi> qpi;

const int mod = int(1e9 + 7);
const double PI = acos(-1.0);

#define ones(x) (__builtin_popcount(x))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define sqr(x) ((x)*(x))

#define len length()
#define sz size()
#define pb push_back
#define mp make_pair
#define s second
#define f first

#define inf 1000000000
#define linf 100000000000ll
#define eps (1e-7)

#define forit(it,S) for(__typeof(S.begin()) it = S.begin(); it != S.end(); ++it)
#define Fill(a,x) memset(a, x, sizeof(a))

#define For(i,a,b)  for(int _b=(b), i=(a); i <= _b; i++)
#define ForD(i,a,b) for(int i=(a), _b=(b); i >= _b; i--)

#define all(c) (c).begin(), (c).end()
#define Sort(c) sort(all(c))
#define Rev(c) reverse(all(c))

const int N = 500000;

int ans[N],p[N];

int next(int l){
	if(l!=p[l]) p[l] = next(p[l]);

	return p[l];
}

int main ()
{

	int n,m,i,l,r,x;

	cin>>n>>m;

	for(i=1;i<=n+1;i++){
		p[i] = i;
		ans[i] = 0;
	}

	for(i=0;i<m;i++){
		cin>>l>>r>>x;

		l = next(l);
		while(l<=r){
		    if(l==x) l++;
		    else{
		    	ans[l] = x;
		    	p[l] = l+1;
		    	l++;
		    }

            l =  next(l);
		}
	}

	for(i=1;i<=n;i++) cout<<ans[i]<<" ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define pb push_back

const int N = 100100;

int b[5],u[N];

int i,n,m,x,y,z;

void check(int x){
	if(u[x]==0){
		int i;

		for(i=1;i<=3;i++)
			if(b[i]==0)break;

		u[x] = i;
		b[i] = 1;
	}
}

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

	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y>>z;

		for(int j = 1;j<=3;j++) b[j] = 0;

        b[u[x]]=1;
        b[u[y]]=1;
        b[u[z]]=1;

		check(x);
		check(y);
		check(z);
	}

    for(i=1;i<=n;i++) cout<<u[i]<<" ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

#define pb push_back

const int N = 100100;

vector<int> a[N];
int b[N][5],u[N];

void fill(int el,int c){
	u[el] = c;

	for(int i=0;i<a[el].size();i++)
		b[a[el][i]][c] = 0;
}

int i,n,m,x,y,z;

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

	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x>>y>>z;

		a[x].pb(y);
		a[x].pb(z);
		a[y].pb(x);
		a[y].pb(z);
		a[z].pb(y);
		a[z].pb(x);
	}

	for(i=1;i<=n;i++){
		u[i] = 0;
		for(x=1;x<4;x++) b[i][x] = 1;
	}

    for(i=1;i<=n;i++)
    	if(u[i]==0){
    		for(x=1;x<4;x++)
    			if(b[i][x]) break;

    		fill(i,x);
    	}

    for(i=1;i<=n;i++) cout<<u[i]<<" ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int>  pi;
typedef vector<int>    vi;
typedef vector<pi>	   vpi;
typedef vector<vi>	   vvi;
typedef queue<pi> qpi;

const int mod = int(1e9 + 7);
const double PI = acos(-1.0);

#define ones(x) (__builtin_popcount(x))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define sqr(x) ((x)*(x))

#define len length()
#define sz size()
#define pb push_back
#define mp make_pair
#define s second
#define f first

#define inf 1000000000
#define linf 100000000000ll
#define eps (1e-7)

#define forit(it,S) for(__typeof(S.begin()) it = S.begin(); it != S.end(); ++it)
#define Fill(a,x) memset(a, x, sizeof(a))

#define For(i,a,b)  for(int _b=(b), i=(a); i <= _b; i++)
#define ForD(i,a,b) for(int i=(a), _b=(b); i >= _b; i--)

#define all(c) (c).begin(), (c).end()
#define Sort(c) sort(all(c))
#define Rev(c) reverse(all(c))

struct dan{
    int f,s,t;
};

vector<int> a[100100];
int b[100100][5];
int u[100100];
dan c[100100];
int m;

bool check(int x,int c){
	for(int i=0;i<a[x].size();i++)
		if(b[a[x][i]][c]) return 0;

	return 1;
}

void fill(int x,int c){
	for(int i=0;i<a[x].size();i++)
		b[a[x][i]][c] = 1;
}

int in(int i){
	if(c[i].f==0) return c[i].f;
	if(c[i].s==0) return c[i].s;

	return c[i].t;
}

void norm(int x){
	int i;

	for(i=1;i<=3;i++)
		if(b[x][i]==0) break;

	x = in(x);
	u[x] = i;
	fill(x,i);
}

void check2(){
	for(int i=0;i<m;i++)
		if(b[i][3]+b[i][1]+b[i][2]==2) norm(i);
}

int n,i,x;

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

	cin>>n>>m;
	for(i=0;i<m;i++){
	    cin>>c[i].f>>c[i].s>>c[i].t;

		a[c[i].f].pb(i);
		a[c[i].s].pb(i);
		a[c[i].t].pb(i);
	}

	for(i=1;i<=n;i++)
		if(!u[i]){
			for(x = 1; x<4; x++)
				if(check(i,x)){
					fill(i,x);
					u[i] = x;
					break;
				}

			check2();
		}

	for(i=1;i<=n;i++) cout<<u[i]<<" ";

	return 0;
}


#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int>  pi;
typedef vector<int>    vi;
typedef vector<pi>	   vpi;
typedef vector<vi>	   vvi;
typedef queue<pi> qpi;

const int mod = int(1e9 + 7);
const double PI = acos(-1.0);

#define ones(x) (__builtin_popcount(x))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define sqr(x) ((x)*(x))

#define len length()
#define sz size()
#define pb push_back
#define mp make_pair
#define s second
#define f first

#define inf 1000000000
#define linf 100000000000ll
#define eps (1e-7)

#define forit(it,S) for(__typeof(S.begin()) it = S.begin(); it != S.end(); ++it)
#define Fill(a,x) memset(a, x, sizeof(a))

#define For(i,a,b)  for(int _b=(b), i=(a); i <= _b; i++)
#define ForD(i,a,b) for(int i=(a), _b=(b); i >= _b; i--)

#define all(c) (c).begin(), (c).end()
#define Sort(c) sort(all(c))
#define Rev(c) reverse(all(c))

vector<int> a[100100];
int b[100100][5];
int u[100100];

bool check(int x,int c){
	for(int i=0;i<a[x].size();i++)
		if(b[a[x][i]][c]) return 0;

	return 1;
}

void fill(int x,int c){
	for(int i=0;i<a[x].size();i++)
		b[a[x][i]][c] = 1;
}

int n,m,i,x;

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

	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>x;
		a[x].pb(i);
		cin>>x;
		a[x].pb(i);
		cin>>x;
		a[x].pb(i);
	}

	for(i=1;i<=n;i++){
			for(x = 1; x<4; x++)
				if(check(i,x)){
					fill(i,x);
					u[i] = x;
					break;
				}
		}

	for(i=1;i<=n;i++) cout<<u[i]<<" ";

	return 0;
}


#include <iostream>

using namespace std;

int main(){

	int n,m,i;
	cin>>n>>m;

	int a[n+1]={0};

	for(i=0;i<m;i++){
	  	int x,y,z;
	  	cin>>x>>y>>z;

	  	if(!a[x])
          a[x]=1;

		if(!a[y]){
			if(a[x]==2)
			  a[y]=1;
			else
			  a[y]=2;
		}

		if(!a[z]){
			if(a[x]==3)
			 a[z]=1;
			else if(a[y]==3)
			 a[z]=2;
			else
			 a[z]=3;
		}
	}

	for(i=1;i<=n && cout<<a[i]<<" ";i++);

	return 0;
}


#include <iostream>

using namespace std;

int main(){

	int n,m,i;
	cin>>n>>m;

	int a[n+1]={0};

	for(i=0;i<m;i++){
	  	int x,y,z;
	  	cin>>x>>y>>z;

	  	if(!a[x])
          a[x]=1;

		if(!a[y]){
			if(a[x]==2)
			  a[y]=1;
			else
			  a[y]=2;
		}

		if(!a[z]){
			if(a[x]+a[y]==3)
			 a[z]=3;
			else if(a[x]+a[y]==4)
			 a[z]=2;
			else
			 a[z]=1;
		}
	}

	for(i=1;i<=n && cout<<a[i]<<" ";i++);

	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100001;
struct dance {
    int a[4];
}d[maxn];
int N, M, c[maxn];
bool cmp(dance a, dance b) {
    if (a.a[1]==b.a[1]) {
        if (a.a[2]==b.a[2]) {
            return a.a[3]<b.a[3];
        }
        return a.a[2]<b.a[2];
    }
    return a.a[1]<b.a[1];
}
int main()
{
    scanf ("%d%d", &N, &M);
    for (int i=1; i<=M; i++) {
        scanf ("%d%d%d", &d[i].a[1], &d[i].a[2], &d[i].a[3]);
        sort(d[i].a+1, d[i].a+4);
    }
    sort(d+1, d+M+1, cmp);
    for (int i=1; i<=M; i++) {
        for (int j=1; j<=3; j++) {
            bool flag = false;
            for (int k=1; k<=3; k++) {
                if (k==j) {
                    continue;
                }
                for (int l=1; l<=3; l++) {
                    if (l==j || l==k) {
                        continue;
                    }
                    if ((c[d[i].a[1]]==0 || c[d[i].a[1]]==j) && (c[d[i].a[2]]==0 || c[d[i].a[2]]==k) && (c[d[i].a[3]]==0 || c[d[i].a[3]]==l)) {
                        c[d[i].a[1]] = j, c[d[i].a[2]] = k , c[d[i].a[3]] = l;
                        flag = true;
                        break;
                    }
                }
                if (flag) break;
            }
            if (flag) break;
        }

    }
    for (int i=1; i<=N; i++) {
        printf ("%d%c", c[i], i==N ? '\n' : ' ');
    }
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100001;
struct dance {
    int a[4];
}d[maxn];
int N, M, c[maxn];
bool cmp(dance a, dance b) {
    if (a.a[1]==b.a[1]) {
        if (a.a[2]==b.a[2]) {
            return a.a[3]<b.a[3];
        }
        return a.a[2]<b.a[2];
    }
    return a.a[1]<b.a[1];
}
bool flag = false;
bool solve(int a, int cur) {
    if (cur==4) {
        return true;
    }
    if (c[d[a].a[cur]]!=0) return solve(a, cur+1);
    bool can[4] = {0};
    for (int i=1; i<=3; i++) {
        can[c[d[a].a[i]]] = 1;
    }
    for (int i=1; i<=3; i++) {
        if (!can[i]) {
            c[d[a].a[cur]] = i;
            if (solve(a, cur+1)) {
                return true;
            } else {
                c[d[a].a[cur]] = 0;
            }
        }
    }
    return false;
}
void dfs(int cur) {
    if (cur == M+1) {
        for (int i=1; i<=N; i++) {
            printf ("%d%c", c[i], i==N ? '\n' : ' ');
        }
        flag = true;
        return;
    }
    if (solve(cur, 1)) {
        dfs(cur+1);
    }
}
int main()
{
    scanf ("%d%d", &N, &M);
    for (int i=1; i<=M; i++) {
        scanf ("%d%d%d", &d[i].a[1], &d[i].a[2], &d[i].a[3]);
        sort(d[i].a+1, d[i].a+4);
    }
    sort(d+1, d+M+1, cmp);
    dfs(1);
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100001;
struct dance {
    int a[4];
}d[maxn];
int N, M, c[maxn];
bool cmp(dance a, dance b) {
    if (a.a[1]==b.a[1]) {
        if (a.a[2]==b.a[2]) {
            return a.a[3]<b.a[3];
        }
        return a.a[2]<b.a[2];
    }
    return a.a[1]<b.a[1];
}
bool flag = false;
bool solve(int a, int cur) {
    if (cur==4) {
        return true;
    }
    if (c[d[a].a[cur]]!=0) return solve(a, cur+1);
    bool can[4] = {0};
    for (int i=1; i<=3; i++) {
        if (can[c[d[a].a[i]]]) {
            for (int j=1; j<=3; j++) {
                if (!can[j]) {
                    c[d[a].a[i]] = j;
                    break;
                }
            }
        }
        can[c[d[a].a[i]]] = 1;
    }
    for (int i=1; i<=3; i++) {
        if (!can[i]) {
            c[d[a].a[cur]] = i;
            if (solve(a, cur+1)) {
                return true;
            } else {
                c[d[a].a[cur]] = 0;
            }
        }
    }
    return false;
}
void dfs(int cur) {
    if (cur == M+1) {
        for (int i=1; i<=N; i++) {
            printf ("%d%c", c[i], i==N ? '\n' : ' ');
        }
        flag = true;
        return;
    }
    if (solve(cur, 1)) {
        dfs(cur+1);
    }
}
int main()
{
    scanf ("%d%d", &N, &M);
    for (int i=1; i<=M; i++) {
        scanf ("%d%d%d", &d[i].a[1], &d[i].a[2], &d[i].a[3]);
        sort(d[i].a+1, d[i].a+4);
    }
    sort(d+1, d+M+1, cmp);
    dfs(1);
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
using namespace std;

void dfs(int start, vector <vector<int> > &g, int fl, int lastf, vector <int> &us)
{
    us[start] = fl;

    int fi = (fl + 1) % 3, fn = (fi + 1) % 3;
    for (unsigned i = 0; i < g[start].size(); i++)
    {
        swap(fi, fn);
        if (fn == lastf);
        swap(fi, fn);

        dfs(g[start][i], g, fn, us[start], us);
    }
}

int main()
{
    freopen("input.txt","r",stdin);
    long n, m;
    scanf("%ld %ld",&n, &m);
    vector <int> dancers(n+1, -1);

    vector < vector<int> > graph(n+1);

    for (int i = 1; i<m+1; i++)
    {
        int j, k;
        scanf("%d %d",&j, &k);
        graph[j].push_back(k);
        j=k;
        scanf("%d",&k);
        graph[j].push_back(k);
    }
    for (int i = 1; i < n+1; i++)
        if (dancers[i]==-1)
            dfs(i, graph, 0,-1, dancers);
    for (int i = 1; i<n+1; i++)
        cout << dancers[i]+1 << " ";
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
using namespace std;

void dfs(int start, vector <vector<int> > &g, int fl, int lastf, vector <int> &us)
{
    us[start] = fl;

    int fi = (us[start] + 1) % 3, fn = (fi + 1) % 3;
    for (unsigned i = 0; i < g[start].size(); i++)
    {
        swap(fi, fn);
        if (fn == lastf)
            swap(fi, fn);

        dfs(g[start][i], g, fn, us[start], us);
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    long n, m;
    scanf("%ld %ld",&n, &m);
    vector <int> dancers(n+1, -1);

    vector < vector<int> > graph(n+1);

    for (int i = 1; i<m+1; i++)
    {
        int j, k;
        scanf("%d %d",&j, &k);
        graph[j].push_back(k);
        j=k;
        scanf("%d",&k);
        graph[j].push_back(k);
    }
    for (int i = 1; i < n+1; i++)
        if (dancers[i]==-1)
            dfs(i, graph, 0,-1, dancers);
    for (int i = 1; i<n+1; i++)
        cout << dancers[i]+1 << " ";
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
using namespace std;

void dfs(int start, vector <vector<int> > &g, int fl, int lastf, vector <int> &us)
{
    us[start] = fl;
    lastf = fl;
    int fi = (fl + 1) % 3, fn = (fi + 1) % 3;
    for (unsigned i = 0; i < g[start].size(); i++)
    {
        swap(fi, fn);
        if (fn == lastf);
        swap(fi, fn);
        dfs(g[start][i], g, fn, lastf, us);
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    long n, m;
    scanf("%ld %ld",&n, &m);
    vector <int> dancers(n+1, -1);

    vector < vector<int> > graph(n+1);

    for (int i = 1; i<m+1; i++)
    {
        int j, k;
        scanf("%d %d",&j, &k);
        graph[j].push_back(k);
        j=k;
        scanf("%d",&k);
        graph[j].push_back(k);
    }
    for (int i = 1; i < n+1; i++)
        if (dancers[i]==-1)
            dfs(i, graph, 0,2, dancers);
    for (int i = 1; i<n+1; i++)
        cout << dancers[i]+1 << " ";
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    long n, m;
    scanf("%ld %ld",&n, &m);
    vector <int> dancers(n+1, -1);

    for (int i = 1; i<m+1; i++)
    {
        int d1, d2, d3;
        scanf("%d %d %d",&d1,&d2,&d3);
        if (dancers[d1]==dancers[d2] && dancers[d2]==dancers[d3])
        {
            dancers[d1]=0;
            dancers[d2]=1;
            dancers[d3]=2;
        }
        else
        {
            if (dancers[d1]!=-1)
            {
                dancers[d2]=(dancers[d1]+1)%3;
                dancers[d3]=(dancers[d2]+1)%3;
            }
            else if (dancers[d2]!=-1)
            {
                dancers[d3]=(dancers[d2]+1)%3;
                dancers[d1]=(dancers[d3]+1)%3;
            }
            else if (dancers[d3]!=-1)
            {
                dancers[d1]=(dancers[d3]+1)%3;
                dancers[d2]=(dancers[d1]+1)%3;
            }
        }
    }
    for (int i = 1; i<=n; i++)
        cout << dancers[i]+1 << " ";
    return 0;
}


#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
using namespace std;

void dfs(int start, vector <vector<int> > &g, int fl, int lastf, vector <int> &us)
{
    us[start] = fl;

    int fi = (fl + 1) % 3, fn = (fi + 1) % 3;
    for (unsigned i = 0; i < g[start].size(); i++)
    {
        swap(fi, fn);
        if (fn == lastf);
        swap(fi, fn);

        dfs(g[start][i], g, fn, us[start], us);
    }
}

int main()
{
    //freopen("input.txt","r",stdin);
    long n, m;
    scanf("%ld %ld",&n, &m);
    vector <int> dancers(n+1, -1);

    vector < vector<int> > graph(n+1);

    for (int i = 1; i<m+1; i++)
    {
        int j, k;
        scanf("%d %d",&j, &k);
        graph[j].push_back(k);
        j=k;
        scanf("%d",&k);
        graph[j].push_back(k);
    }
    for (int i = 1; i < n+1; i++)
        if (dancers[i]==-1)
            dfs(i, graph, 0,-1, dancers);
    for (int i = 1; i<n+1; i++)
        cout << dancers[i]+1 << " ";
    return 0;
}


#include <iostream>
using namespace std;

int n, m;
int color[100005];

void assign_color(int a, int b, int c) {
	if (color[a]) {
		color[b] = (color[a] + 1) % 3;
		color[c] = (color[b] + 1) % 3;
	}

	else if (color[b]) {
		color[a] = (color[b] + 1) % 3;
		color[c] = (color[a] + 1) % 3;
	}

	else if (color[c]) {
		color[b] = (color[c] + 1) % 3;
		color[a] = (color[b] + 1) % 3;

	} else {
		color[a] = 0;
		color[b] = 1;
		color[c] = 2;
	}

}

int main() {
	cin >> n >> m;
	int a, b, c;

	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		assign_color(a, b, c);
	}

	for (int i = 1; i <= n; i++) {
		cout << color[i]+1 << ' ';
	}

	return 0;
}


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

int n, m;
int color[100005] = {-1};

void assign_color(int a, int b, int c) {
	if (color[a] != -1) {
		color[b] = (color[a] + 1) % 3;
		color[c] = (color[b] + 1) % 3;
	}

	else if (color[b] != -1) {
		color[a] = (color[b] + 1) % 3;
		color[c] = (color[a] + 1) % 3;
	}

	else if (color[c] != -1) {
		color[b] = (color[c] + 1) % 3;
		color[a] = (color[b] + 1) % 3;

	} else {
		color[a] = 0;
		color[b] = 1;
		color[c] = 2;
	}

	//printf("%d %d %d : %d %d %d\n", a, b, c, color[a], color[b], color[c]);
}

int main() {
	cin >> n >> m;
	int a, b, c;

	for (int i = 0; i <=n; i++)
		color[i] = -1;

	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		assign_color(a, b, c);
	}

	for (int i = 1; i <= n; i++) {
		cout << color[i]+1 << ' ';
	}

	return 0;
}


#include <iostream>
using namespace std;

int n, m;
int color[100005];

void assign_color(int a, int b, int c) {
	if (color[a]) {
		color[b] = (color[a] + 1) % 3;
		color[c] = (color[b] + 1) % 3;
	}

	else if (color[b]) {
		color[a] = (color[b] + 1) % 3;
		color[c] = (color[a] + 1) % 3;
	}

	else if (color[c]) {
		color[b] = (color[c] + 1) % 3;
		color[a] = (color[b] + 1) % 3;

	} else {
		color[a] = 1;
		color[b] = 2;
		color[c] = 3;
	}

}

int main() {
	cin >> n >> m;
	int a, b, c;

	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		assign_color(a, b, c);
	}

	for (int i = 1; i <= n; i++) {
		if (color[i] == 0)
			color[i] = 3;
		cout << color[i] << ' ';
	}

	return 0;
}


#include <iostream>
using namespace std;

int n, m;
int color[100005] = {-1};

void assign_color(int a, int b, int c) {
	if (color[a] != -1) {
		color[b] = (color[a] + 1) % 3;
		color[c] = (color[b] + 1) % 3;
	}

	else if (color[b] != -1) {
		color[a] = (color[b] + 1) % 3;
		color[c] = (color[a] + 1) % 3;
	}

	else if (color[c] != -1) {
		color[b] = (color[c] + 1) % 3;
		color[a] = (color[b] + 1) % 3;

	} else {
		color[a] = 0;
		color[b] = 1;
		color[c] = 2;
	}

}

int main() {
	cin >> n >> m;
	int a, b, c;

	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		assign_color(a, b, c);
	}

	for (int i = 1; i <= n; i++) {
		cout << color[i]+1 << ' ';
	}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=102;
int s[3];
int ans[maxn];
int main()
{
    int i,j,k;
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(ans,-1,sizeof(ans));
      // int ans[n+1];
       //for(i=1;i<=n;i++)
       // ans[i]=-1;
        int l=0;
        for(i=0;i<m;i++)
        {
             k=1;
            for(j=0;j<3;j++)
            {
             // scanf("%d",&s[j]);
               cin>>s[j];
              if(ans[s[j]]!=-1)
              {
                  l=ans[s[j]];
              }
            }
           for(j=0;j<3;j++)
               if(ans[s[j]]!=l)
               {
                   ans[s[j]]=(l+k)%3;
                   k++;
               }
        }
        for(i=1;i<=n;i++)
            printf("%d ",ans[i]+1);
            printf("\n");
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100002;
int s[3];
int ans[maxn];
int main()
{
    int i,j,k;
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        memset(ans,-1,sizeof(ans));
      // int ans[n+1];
       //for(i=1;i<=n;i++)
       // ans[i]=-1;
        int l=0;
        for(i=0;i<m;i++)
        {
             k=1;
            for(j=0;j<3;j++)
            {
             // scanf("%d",&s[j]);
               cin>>s[j];
              if(ans[s[j]]!=-1)
              {
                  l=ans[s[j]];
              }
            }
           for(j=0;j<3;j++)
               if(ans[s[j]]!=l)
               {
                   ans[s[j]]=(l+k)%3;
                   k++;
               }
        }
        for(i=1;i<=n;i++)
            printf("%d ",ans[i]+1);
            printf("\n");
    }
    return 0;
}