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++: //16D8104001K 田中誠人 makoto0106 c++
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  std::vector<int>num;
  int n,k,tmp,x,size;

  std::cin>>n;
  
  for(int i=0;i<n;i++){
    std::cin>>tmp>>k;
    num.push_back(k);
    for(int j=0;j<k;j++){
      std::cin>>tmp;
      num.push_back(tmp);
      //std::cout<<tmp<<" ";
    }
  }
  size=num.size();
  /*
  for(int i=0;i<size;i++){
    std::cout<<num[i]<<" ";
  }
  */
  x=0;
  std::cout<<"\n";
  while(x<size){
    if(num[x]==0){
      for(int i=0;i<n;i++){
	std::cout<<"0 ";
      }
      x++;
    }else{
      x++;
      for(int i=0;i<n;i++){
      
	if(i+1==num[x]){
	  std::cout<<"1 ";
	  x++;
	}else{
	  std::cout<<"0 ";
	}
      }
    }
    std::cout<<"\n";
  }
  

  std::cout<<"\n";

  
  return 0;
}
/*実行結果
4
1 2 2 4
2 1 4
3 0
4 1 3

0 1 0 1 
0 0 0 1 
0 0 0 0 
0 0 1 0 

*/

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

int main() {
	int n,graph[100][100];
	cin >> n;

	for (int i = 0; i < n; i++) {
		int vertex,jisu;
		cin >> vertex>>jisu;
		for (int j = 0; j < jisu; j++) {
			int to;
			cin >> to;
			graph[vertex-1][to-1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (graph[i][j] != 1) graph[i][j] = 0;
			cout << graph[i][j];
			if (j < n - 1)cout << " ";
			else cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}

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

int main() {
	int n, u, k, v;
	cin >> n;
	vector<vector<bool>> am(n, vector<bool>(n));
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v;
			am[u - 1][v - 1] = true;
		}
	}
	for (vector<bool>& i : am) {
		cout << i[0];
		for (int j = 1; j < n; ++j) cout << ' ' << i[j];
		cout << endl;
	}
}

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

int main(){
  int n;
  cin>>n;

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

C++: #include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

void solve() {
    int n; cin >> n;
    vector<vector<int>> a(n, vector<int>(n,0));
    Rep(i, 1, n){
        ll u, k; cin >> u >> k;
        rep(i, 0, k){
            ll v; cin >> v;
            a[u-1][v-1] = 1;
        }
    }
    rep(i, 0, n){
        rep(j, 0, n){
            if(j) cout << " ";
            cout << a[i][j];
        }
        cout << "\n";
    }

    return;
}

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

    solve();
    return 0;
}

C++: #include <iostream>
#include <vector>


int main(int argc, char const *argv[]) {
  int n; // .. 100
  std::cin >> n;


  std::vector<std::vector<bool> > adj(n, std::vector<bool>(n));

  for(int q=0; q<n; ++q){
    int i_plus_1, k;
    std::cin >> i_plus_1;
    std::cin >> k;
    for(int p=0; p<k; ++p){
      int j_plus_1;
      std::cin >> j_plus_1;
      adj[i_plus_1-1][j_plus_1-1] = true;
    }
  }

  for(int i=0; i<n; ++i){
      for(int j=0; j<n; ++j){
        std::cout  <<  adj[i][j] << (j==n-1 ? "" : " "); 
      }
      std::cout << std::endl;
  }

  return 0;
}

C++: #include<iostream>
int main(){
  int n;
  std::cin>>n;
  int i,j;
  int u[n],k;
  int a[n][n];
  //行列の初期化
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      a[i][j]=0;
    }
  }
  
  for(i=0; i<n; i++){
    std::cin>>u[i];
    std::cin>>k;
    for(j=0; j<k; j++){
      int v;
      std::cin>>v;
      a[i][v-1]=1;
    }
  }
  for(i=0; i<n; i++){
    for(j=0; j<n-1; j++){
      std::cout<<a[i][j]<<" ";
    }
    std::cout<<a[i][n-1]<<"\n";
  }
}

C++: #include<iostream>
int main(){
    int n;
    std::cin>>n;
    int A[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            A[i][j]=0;
        }
    }
    int tmp,s,e;
    for(int i=0;i<n;i++){
        std::cin>>s;
        std::cin>>tmp;
        for(int j=0;j<tmp;j++){
            std::cin>>e;
            A[s-1][e-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
                std::cout<<A[i][j];
            }else std::cout<<" "<<A[i][j];
        }
        std::cout<<std::endl;
    }
    return 0;
}

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

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

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

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

C++: #include<iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REP(j, n) for(int j = 0;j < n;j++)
using namespace std;

int main()
{
	int i,n,u,k;
	int v[100][100];
	cin >> n;
	REP(i,n){
		cin >> u;
		cin >> k;
		REP(i,k){
			cin >>v[i][k];
		}
	}
	REP(i,n){
		REP(j,n){
			cout << v[i][j] << " ";
		}
		cout<<endl;
	}
}