Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	graph := make([][]int, n)
	for i := 0; i < n; i++ {
		graph[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		s := nextInt()
		t := nextInt()
		if t == 0 {
			continue
		}
		for i := 0; i < t; i++ {
			u := nextInt()
			graph[s-1][u-1] = 1
		}
	}
	for i := range graph {
		for j := range graph[i] {
			if j == n-1 {
				fmt.Printf("%d\n", graph[i][j])
			} else {
				fmt.Printf("%d ", graph[i][j])
			}
		}
	}
}

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

C++: #include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int n,k[101],v[101][100];
int a[101][101];
int main(void)
{
	int i,u,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		for(j=1;j<=n;j++)	{
			a[i][j]=0;
		}
	}
	for(i=1;i<=n;i++)	{
		scanf("%d %d",&u,&k[i]);
		for(j=0;j<k[i];j++)	{
			scanf("%d",&v[i][j]);
			a[u][v[u][j]]=1;
		}
	}
	for(i=1;i<=n;i++)	{
		printf("%d",a[i][1]);
		for(j=2;j<=n;j++)	{
			printf(" %d",a[i][j]);
		}
		printf("\n");
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);
#define int long long
int a[600000];

signed main(){
	int ans[100][100]={};
	int n,d,k,v;
	cin>>n;
	lp(i,n){
		cin>>d>>k;
		lp(j,k){
			cin>>v;
			ans[d-1][v-1]=1;
		}
	}
	lp(i,n){
		lp(j,n){
			if(j!=0)cout<<" ";
			cout<<ans[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

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 != 0) {
                cout << " ";
            }
            cout << M[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

#define MAX 200

int main(){
    int n; cin >> n;
    vector<vector<int>> adj_mat(MAX, vector<int>(MAX, 0));

    rep(i, n){
        int u, k; cin >> u >> k;

        rep(j, k){
            int v; cin >> v;
            adj_mat.at(u-1).at(v-1) = 1;
        }

    }

    rep(i, n){
        rep(j, n-1){
            cout << adj_mat.at(i).at(j) << " ";
        }
        cout << adj_mat.at(i).at(n-1) << endl;
    }
}

C++: #include<iostream>
#include<windows.h>
using namespace std;
int graph[105][105];
int main()
{
	int n;
	cin>>n;
	memset(graph,0,sizeof(graph));
	for(int i=1;i<=n;i++)
	{
		int v;
		cin>>v;
		int num;
		cin>>num;
		while(num--)
		{
			int aa;
			cin>>aa;
			graph[v-1][aa-1]=1;
			//cout<<v-1<<" "<<aa<<endl;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(j>0)
			cout<<" ";
			cout<<graph[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int M[n][n];
    // 隣接行列の初期化
    rep(i,n) rep(j,n) M[i][j] = 0;
    // 隣接リストを読み込む
    rep(i,n){
        int u; cin >> u; u--;   // 二次元配列のインデックスに合うように頂点番号をデクリメント
        int k; cin >> k;
        rep(_,k){
            int vi; cin >> vi; vi--;
            M[u][vi] = 1;
        }
    }
    rep(i,n){
        rep(j,n){
            cout << M[i][j];
            if(j != n-1) cout << " ";
        }
        cout << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
  int g[10010][10010]={};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++j)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
#include <cstdio>
#include <stdlib.h>
using namespace std;

int main() 
{
	int n;
	scanf("%d", &n);
	
	int M[n][n]; //initialize? 

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

	for(int i = 1; i <= n; i++)   
	{
		int u,k,v;
		scanf("%d %d", &u, &k);
		for(int j = 0; j < k; j++)
		{
			scanf("%d", &v);
			M[u-1][v-1] = 1;
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(j) printf(" ");
			printf("%d", M[i][j]);
		}
		printf("\n");
	}
	
//	system("pause");
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	int m[101][101];
	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++){
		int u, k; cin >> u >> k;
		for(int j=0;j<k;j++){
			int v; cin >> v;
			m[u-1][v-1] = 1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n-1;j++){
			cout  << m[i][j] << ' ';
		}
		cout << m[i][n-1] << endl;
	}
	return 0;
}

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