https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=666
#include<bits/stdc++.h>
using namespace std;
const int maxn=10010;
vector<pair<int,int> > g[maxn];
int main(){
int a[10]={0,1,2,3,4,5,6,7,8,9};
do{
int d2=a[0]*10000+a[1]*1000+a[2]*100+a[3]*10+a[4];
int d1=a[5]*10000+a[6]*1000+a[7]*100+a[8]*10+a[9];
if((d1