#include using namespace std; typedef long long ll; int a[3005],n,m,u,v,w,ans; int main() { while(~scanf("%d %d",&n,&m)) { ans = 0x7fffffff; memset(a,0,sizeof(a)); for(int i=0;i