Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int n,u,k,v;
    scanf("%d",&n);
    int A[n+1][n+1];
    for(int i = 0; i <= n; i++){
        for(int j =0 ; j <= n; j++) A[i][j] = 0;
    }
    for(int i = 1; i <= n; i++){
        scanf("%d %d",&u,&k);
        for(int j = 0; j < k; j++){
            scanf("%d",&v);
            A[u][v] = 1;
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            printf("%d",A[i][j]);
            if(j != n) printf(" ");
        }
        printf("\n");
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v;

	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
    int M[100][100];
    int n, u, k, v;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            M[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        for(int j =0; j < k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
	int n; cin >> n;
	int ga[n][n];
	memset(ga, 0, n*n*sizeof(int));
	rep(i, n){
		int u, k; cin >> u >> k;
		rep(j, k){
			int v; cin >> v;
			ga[u-1][v-1] = 1;
		}
	}

	rep(i, n)rep(j, n) cout << ga[i][j] << char((j == n-1)?'\n':' ');
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
using namespace std;

int n;
int adj[110][110] = {};

int main() {
  cin >> n;
  rep(i, n) {
    int id, deg;
    cin >> id >> deg;
    --id;    // 0-indexedに直す
    rep(j, deg) {
      int v;
      cin >> v;
      --v;    // 0-indexedに直す
      ++adj[id][v];
    }
  }
  rep(i, n) {
    rep(j, n) {
      cout << adj[i][j] << ((j != n - 1)? " " : "\n");
    }
  }
  return 0;
}

C++: #include <iostream>
#define rep(i,n) for(int i = 0 ; i < n ; i++)

using namespace std;

int G[100][100];

int main(){
  int V;

  cin >> V;

  rep(i,V){
    int u,k,v;

    cin >> u >> k;
    rep(j,k){
      cin >> v;
      G[u-1][v-1] = 1;
    }
  }

  rep(i,V){
    rep(j,V){
      if(j == V-1) cout << G[i][j] << endl;
      else cout << G[i][j] << " ";
    }
  }

  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    int u, k;
    vector<vector<bool>> graph(n, vector<bool>(n, false));
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        u--;
        int v;
        for (int j = 0; j < k; j++){
            cin >> v;
            v--;
            graph[u][v] = true;
        }
    }
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            cout << graph[i][j];
            if (j == n - 1)
                cout << endl;
            else
                cout << ' ';
        }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define MAX 100

int main() {
  int n;
  cin >> n;
  int a[MAX][MAX];
  int len[MAX];
  int a_list[n+1][n+1];

  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < n+1; j++) {
      a_list[i][j] = 0; //ゼロで初期化
    }
  }

  for (int i = 1; i < n+1; i++) {
    int index, k;
    cin >> index >> k;
    for (int j = 1; j < k+1; j++) {
      int tmp;
      cin >> tmp;
      a_list[i][tmp] = 1;
    }
  }

  for (int i = 1; i < n+1; i++) {
    for (int j = 1; j < n+1; j++) {
      if (j != 1) cout << " ";
      cout << a_list[i][j];
    }
    cout << endl;
  }

  return 0;
}

C++: // AOJ
// ALDS1_11_A Graph
// https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_11_A
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }

int main() {
    int n; cin >> n;
    vvi g(n, vi(n, 0));
    rep(i, n) {
        int u, k; cin >> u >> k; u--;
        rep(j, k) {
            int v; cin >> v; v--;
            g[u][v] = 1;
        }
    }

    rep(i, n) cout_h(g[i]);
}

C++: 
#include <iostream>
using namespace std;

int graph[101][101];

int main() {
    int n;
    int u,k,v;
    cin >> n;
    for(int i=0;i<n;i++) {
        cin >> u >> k;
        for(int j=0;j<k;j++) {
            cin >> v;
            if(graph[u][v] == 0)
                graph[u][v] = 1;
        }
    }
    
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            cout << graph[i][j] << (j==n ? "\n" : " ");
        }
    }
}

C++: #include <iostream>
#include <cstdio> 
using namespace std;
/*---------------------------------------------------*/

int main(){
  int n,u,k,v;
  int g[101][101]={};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(int i=0;i<k;i++){
      scanf("%d",&v);
      g[u][v]=1;
    }
  }
  for(int i=1;i<n+1;i++){
    printf("%d",g[i][1]);
    for(int j=2;j<n+1;j++){
      printf(" %d",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,a,b,c;
  int adj[100][100]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    for(int j=0;j<b;j++){
      cin>>c;
      adj[i][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)cout<<' ';
      cout<<adj[i][j];
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <cstdio> 
using namespace std;
int G[100][100];

int main()
{
    int n;
    cin>>n;
    int u,v,k;
    for (int i = 0; i < n; i++)
    {
        cin>>u>>k;
        for (int j = 0; j < k; j++)
        {
            cin>>v;
            G[u-1][v-1] = 1;
        } 
    } 
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout<<G[i][j];
            if (j!=n-1) cout<<" ";
        }  
        cout<<endl;
    } 
    return 0;
}

C++: //????????°??????
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int main(){
	int n;
	cin>>n;
	vector<vector<int> > Adj(n, vector<int>(n, 0));
	REP(i,n){
		int u,k;
		cin>>u>>k;
		REP(j,k){
			int l;
			cin>>l;
			//u==j+1??§??????
			Adj[u-1][l-1]=1;
		}
	}
	REP(i,n){
		REP(j,n-1){
			cout<<Adj[i][j]<<" ";
		}
		cout<<Adj[i][n-1]<<endl;
	}
	return 0;
}