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 <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class Graph
{
public:
  int solve();
};

int Graph::solve()
{
  int n;
  cin >> n;
  
  vector<vector<int>> adj( n + 1, vector<int>( n + 1, 0 ) );
  
  for ( auto i = 0; i < n; ++i )
    {
      int u;
      int k;
      int v;
      cin >> u;
      cin >> k;
      for ( auto j = 0; j < k; ++j )
        {
          cin >> v;
          adj[u][v] = 1;
        }
    }

  for ( auto i = 1; i <= n; ++i )
    {
      for ( auto j = 1; j <= n; ++j )
        {
          if ( j > 1 ) cout << " ";
          cout << adj[i][j];
        }
      cout << endl;
    }
  
  return 0;
}

int main()
{
  Graph g;

  g.solve();

  return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<vector<ll>> mat(n,vector<ll>(n,0));
    for(ll i=0;i<n;i++) {
        ll u,k;
        cin>>u>>k;
        for(ll j=0;j<k;j++) {
            ll tmp;
            cin>>tmp;
            mat[u-1][tmp-1] = 1;
        }
    }
    for(ll i=0;i<n;i++) {
        for(ll j=0;j<n;j++) {
            cout << mat[i][j] << " ";
        }
        cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
int a[105][105];

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

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

int main(){
	int graph[100][100] = {};
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++) {
			int t;
			cin >> t;
			graph[now - 1][t - 1] = 1;
		}
	}
	for(int i = 0;i < n;i++){
		cout << graph[i][0];
		for(int j = 1;j < n;j++){
			cout << " " << graph[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;

vector<vector<int>> G;
int G2[100][100];

void input_graph(int n) {
    int u, k, v;
    rep(i, n) {
        vector<int> vec;
        cin >> u >> k;
        u--;
        rep(j, k) {
            cin >> v;
            v--;
            vec.push_back(v);
        }
        G.push_back(vec);
    }
}

void input_graph2(int n) {
    int u, k, v;
    rep(i, n) {
        cin >> u >>k;
        u--;
        rep(j,k){
            cin >> v;
            v--;
            G2[u][v]=1;
        }
    }
}

void print_graph2(int n){
    rep(i,n){
        rep(j,n){
            cout<<G2[i][j];
            if(j<n-1){
                cout << " ";
            }
        }
        cout << endl;
    }
}

void print_graph() {
    rep(i, G.size()) {
        rep(j, G[i].size()) {
            printf("%d", G[i][j]);
            if(j < G[i].size() - 1)
                printf(" ");
        }
        printf("\n");
    }
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;
    input_graph2(n);
    print_graph2(n);
}

C++: #include<iostream>
#include<cstdio>
#define N 101
using namespace std;

int main(){

  int n,n2,data,u;
  int g[N][N]; 
 //load n
  cin >>n;

  //initialize
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      g[i][j]=0;
    }
  }

  //load data
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }
  //print
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      printf("%d",g[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }

  return 0;
}

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

int main(){
    int n;

    cin >> n;
    vector<vector<int>> a(n, vector<int>(n, 0));

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

    for(auto vv: a){
        for(int i = 0; i < n; i++){
            cout << vv[i];
            if(i != n - 1){
                cout << " ";
            }
        }
        cout << endl;
    }

    return 0;
}

C++:     #include <iostream>
    using namespace std;
     
    int main() {
    int k[105][105]={0};
    int n,l,a,b;
    cin>>n;
    for(int j=0;j<n;j++){
    cin>>l>>a;
    for(int i=0;i<a;i++){
    cin>>b;
    k[j][b-1]=1;
    }
    }
     
    for(int r=0;r<n;r++){
    for(int e=0;e<n-1;e++){
    cout<<k[r][e]<<" ";
    }
    cout<<k[r][n-1]<<endl;
    }
    return 0;
    }

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

int main() {
  int M[N][N];  // 0 オリジンの配列
  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--;  // 0 オリジンへ変換
    for ( int j = 0; i < n; j++ ) {
      cin >> v;
      v--;  // 0 オリジンへ変換
      M[u][v];  // u と v の間に辺を張る
    }
  }

  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 <stack>
#include <queue>
#include <cstdlib>
#include <iomanip>
#include <utility>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>

using namespace std;

int main() {
    int c;
    string s;
    getline(cin,s);
    c = atoi(&s[0]);
    int a[c][c];
    for(int i = 0;i<c;i++)
        for(int j = 0;j<c;j++)
            a[i][j] = 0;
    for (int i = 0; i <c;i++)
    {
        bool first = true;
        getline(cin, s);
        string::iterator ite = s.begin();
        while (ite != s.end())
        {
            if(*ite != ' ')
            {
                int n = atoi(&*ite);
                if(*(ite+1) != ' ' && ite+1 != s.end())
                {
                    n *= 10;
                    n += atoi(&*(++ite));
                    if(*(ite+1) != ' ' && ite+1 != s.end())
                    {
                        n*=10;
                        n+= atoi(&*(++ite));
                    }
                }
                if(first)
                    first = false;
                else
                    a[i][n-1] = 1;
            }
            ite++;
        }
    }
    for(int i = 0;i < c;i++)
    {
        for(int j = 0; j<c-1;j++)
        {
            cout << a[i][j] << " ";
        }
        cout << a[i][c-1] << endl;
    }
    
    return 0;
}

C++: #include <cstdio>
#include <cstring>
int g[101][101];

int main()
{
  memset(g, 0, sizeof(g));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    int u, adj_num;
    scanf("%d%d", &u, &adj_num);
    while (adj_num--)
    {
      int v;
      scanf("%d", &v);
      g[u - 1][v - 1] = 1;
    }
  }
  for (int i = 0; i < n; i++)
  {
    printf("%d", g[i][0]);
    for (int j = 1; j < n; j++)
    {
      printf(" %d", g[i][j]);
    }
    printf("\n");
  }
}