Go: package main

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

//util
var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func printList(list []int) {
	n := len(list)
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range list[0 : n-1] {
		buf.Write([]byte(fmt.Sprintf("%d ", v)))
	}
	buf.Write([]byte(fmt.Sprintf("%d\n", list[n-1])))
	buf.Flush()
}

func max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

//solve

const MAX = 100

var n int
var A [MAX + 1][MAX + 1]int

func main() {
	sc.Split(bufio.ScanWords)
	n = nextInt()
	for i := 0; i < n; i++ {
		u, k := nextInt(), nextInt()
		A[u-1][u-1] = 0

		//fmt.Println(u, k)
		if k > 0 {
			for j := 0; j < k; j++ {

				v := nextInt()
				A[u-1][v-1] = 1

			}
		}

	}

	for i := 0; i < n; i++ {
		printList(A[i][0:n])
	}

}

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");
  }
}

C++: #include <stdio.h>
#define N 100

int main()
{
  int array[N][N];
  int i,j,n,v,w,x,y;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      for(j=0;j<N;j++)
        {
          array[i][j]=0;
        }
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d",&v,&w);
      v--;
      for(j=0;j<w;j++)
        {
          scanf("%d",&x);
          x--;
          array[v][x]=1;
        }
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
        {
          if(j) printf(" ");
          printf("%d",array[i][j]);
        }
      printf("\n");
    }
  return 0;
}