#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
template<typename TypenameF,int MaxN,int MaxM>
class Graphs{
public:
typedef TypenameF flowtype;
int Last[MaxN
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
template<typename TypenameF,int MaxN,int MaxM>
class Graphs{
public:
typedef TypenameF flowtype;
int Last[MaxN