#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define INF (1<<29)

int G[101][101];
int n, k;

void init(){
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      G[i][j] = INF;
      if(i == j) G[i][j] = 0;
    }
  }
}

int main(){
  while(cin >> n >> k){
    if(n == 0 && k == 0) break;
    init();

    int op, a, b, e;
    for(int cs = 0 ; cs < k ; cs++){
      cin >> op;
      if(op == 1){
	cin >> a >> b >> e;
	a--, b--;
	G[a][b] = min(G[a][b], e);
	G[b][a] = min(G[b][a], e);
	//	Warshall_Floyd();
	  for(int i = 0 ; i < n ; i++){
	    for(int j = 0 ; j < n ; j++){
	      G[i][j] = min(G[i][j], G[i][a] + G[a][b] + G[b][j]);
	      G[j][i] = G[i][j];
	    }
	  }
      }
      else if(op == 0){
	cin >> a >> b;
	a--, b--;
	if(G[a][b] == INF) cout << -1 << endl;
	else cout << G[a][b] << endl;
      }
    }
  }
  return 0;
}
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
    int a[5];
    while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
        sort(a,a+5);
        int n=0;
        rep(i,4)loop(j,i+1,5){
            if(a[i]==a[j])n++;
        }
        bool st=true;
        rep(i,4)if(a[i]+1!=a[i+1])st=false;
        if(a[0]==1&&
           a[1]==10&&
           a[2]==11&&
           a[3]==12&&
           a[4]==13) st=true;

        string ans;
        if(n==6)
            ans="four card";
        else if(n==4)
            ans="full house";
        else if(st)
            ans="straight";
        else if(n==3)
            ans="three card";
        else if(n==2)
            ans="two pair";
        else if(n==1)
            ans="one pair";
        else
            ans="null";
        cout<<ans<<endl;
    }
}