# sgu230（拓扑排序) 231

## 230：

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 110;
int flag ,wi[maxn][maxn],k,t,degree[maxn],ans[maxn];
int n,m,a,b;
void init(){
scanf("%d%d",&n,&m);
for(int i = 1; i <= m ; i++){
scanf("%d%d",&a,&b);
if(wi[a][b] == 0)
degree[b]++;
wi[a][b] = 1;
}
}
void sov(){
for(int i = 1; i <= n ; i++){
for( t = 1;t <= n ; t++){
if(degree[t] == 0)  break;
}
if(t > n ){
flag = 1;
break;
}
for(int j  = 1; j <= n ; j++){
if(wi[t][j])    degree[j]--;
}
ans[t] = i ;degree[t]--;
}
if(flag)    printf("No solution\n");
else
for(int i = 1; i <= n ; i++)
printf("%d%c",ans[i],i == n+1?'\n':' ');
}
int main(){
init();
sov();
}


## 231：

#include <iostream>
using namespace std;
const int maxn = 1e6+10;
bool f[maxn];
int ok[100000],out[10000];
int n, sum, ans;
void sift (int n) {
for (int i = 2; i <= n; i++) {
if (!f[i]) {
ok[++sum] = i;
for (int j = i; j <= n; j += i)    f[j] = 1;
}
}
}
int main() {
cin >> n;
sift (n);
for (int i = 1; i < sum; i++)
if (!f[ok[i] + 2])        out[++ans]=ok[i];

cout << ans << endl;
for(int i=1;i<=ans;i++)
cout<<2<<' '<<out[i]<<endl;
}