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

typedef struct{
  int a,b,t;
}Put;

int main(){
  int n,m;
  scanf("%d %d", &n, &m);
  Put *putevi;
  putevi = (Put*)malloc(m*sizeof(Put));
  for(int i = 0; i < m; i ++){
    scanf("%d %d %d", &putevi[i].a, &putevi[i].b,&putevi[i].t);
  }
  int u,v;
  scanf("%d %d", &u, &v);
  int rez = -1;
  printf("%d", rez);
  return 0;
}