Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

C++: N = int(raw_input())
A = [0] * N
for i in range(N):
  A[i] = [0] * N

for line in sys.stdin:
  values = line.split()
  u = int(values[0]) - 1
  k = int(values[1])
  nodes = values[2:]
  for i in range(int(k)):
    v = int(nodes[i]) - 1
    A[u][v] = 1

for i in range(N):
  print " ".join([str(x) for x in A[i]])

C++: #include<cstdio>

#define MAX_N 100

int n, u, k, v;
int adj[MAX_N][MAX_N];

int main(void){
	scanf("%d", &n);

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

	for(int i = 0; i < n; i++){
		scanf("%d", &u);
		u -= 1;
		scanf("%d", &k);
		for(int j = 0; j < k; j++){
			scanf("%d", &v);
			v -= 1;
			adj[u][v] = 1;
		}
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			printf("%d", adj[i][j]);
			if(j != n - 1){
				printf(" ");
			}
			else if(j == n - 1){
				printf("\n");
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#define N 100

int v[N + 1][N + 1];

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

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

int main(){
    int i,j,n,doudemoii,count,huga;
    cin >> n;
    int ans[n+1000][n+1000];
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
        ans[i][j] = 0;
        }
    }

    for(i=0; i < n; i++){
        cin >> doudemoii >> count;
        for(j = 0; j < count; j++){
            cin >> huga;
            ans[i][huga-1] = 1;
        }
    }
    for(i = 0; i< n; i++){
        for(j = 0; j < n; j++){
            if(j < n-1)cout << ans[i][j] << ' ';
            else cout << ans[i][j] << endl;
        }
    }
}

C++: #include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int main() {
    int N; cin >> N;
    vector<vector<int>> adj(N);
    rep(i, N) adj[i].resize(N);
    rep(i, N) { rep(j, N) adj[i][j] = 0; }

    rep(i, N) {
        int u, k; cin >> u >> k; u--;
        rep(j, k) {
            int v; cin >> v; v--;
            adj[u][v] = 1;
        }
    }
    rep(i, N) {
        rep(j, N) {
            cout << adj[i][j] << (j < N-1 ? " " : "");
        }
        cout << endl;
    }
}

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

int main(){
  
  int n, u, k, v;
  bool a[110][110] = {};
  
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v;
      a[u][v] = true;
    }
  }
  
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      cout << (j - 1?" ":"");
      cout << a[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

C++: #include<iostream>

using namespace std;

#define ll long long

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

    for (ll i=0; i<n; i++){
        for(ll j=0; j<n; j++){
            cout << A[i][j];
            if(j<n-1){
                cout << ' ';
            }
        }
        if(i<n-1){
            cout << '\n';
        }
    }
}

C++: #include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n, 0));
	REP(i, n) {
		int u, k;
		cin >> u >> k;
		u--;
		REP(j, k) {
			int v;
			cin >> v;
			a[u][--v] = 1;
		}
	}
	REP(i, n) {
		REP(j, n) {
			cout << a[i][j];
			if (j < n - 1) cout << " ";
			else cout << "\n";
		}
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i];
    int x;
    cin >> x;
    k[u[i]-1]+=x;

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }

C++: #include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector< vector<int> > G(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            G[u][v] = 1;
        }
    }
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j > 0) cout << " ";
            cout << G[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<vector<int>> vec(N, vector<int>(N, 0));
    for (int i=0; i<N; i++) {
        int index, count;
        cin >> index >> count;
        for (int j=0; j<count; j++) {
            int inx;
            cin >> inx;
            vec[index-1][inx-1] = 1;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            cout << vec[i][j];
            if (j < N-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    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++){
		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;
static int const 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;
	}
}