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++: //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";
  }
  
  
  return 0;
}

C++: // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_A
// Graph I - Graph

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>
#include <memory>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const ui64 MAX_N = 100;
// dp[i][j] [i, j]までの行列をかけたときの最小コスト

int adj[MAX_N][MAX_N];

int main() {
    memset(adj, 0, sizeof(adj));

    int n;
    cin >> n;

    int u, degree;
    for (int i = 0; i < n; ++i) {
        cin >> u >> degree;
        u--; // 0-origin

        int v;
        for (int j = 0; j < degree; ++j) {
            cin >> v;
            v--; //0-origin
            adj[u][v] = 1;
        }
    }

    for (int y = 0; y < n; ++y) {
        for (int x = 0; x < n; ++x) {
            cout << adj[y][x];
            if (x != n -1) cout << " ";
            else cout << endl;
        }
    }

    return 0;
}

C++: #include <iostream>

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

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

C++: #include <stdio.h>
 
int map_max;
int map[110][110];
int rows;
int cols[110];
int mat[110][110] = {};
 
void get_map();
void print_map();
void conv_map();
void print_mat();
 
int main()
{
 
  get_map();
  //print_map();
  conv_map();
  print_mat();
  return 0;
}
 
void get_map()
{
 
  int k;
  scanf("%d", &map_max);//<100
 
  for(int i=0;i<map_max;i++)
    {
      scanf("%d", &k);
      scanf("%d", &cols[i]);
      for(int j=0;j<cols[i];j++)
    {
      scanf("%d", &map[i][j]);
    }
    }
 
   
  return ;
}
 
void print_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      printf("%d", map[i][j]);
    }
      puts("");
    }
return ;
}
 
 
void conv_map()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<cols[i];j++)
    {
      mat[i][map[i][j]-1]=1;
    }
    }
  return ;
}
 
void print_mat()
{
  for(int i=0;i<map_max;i++)
    {
      for(int j=0;j<map_max;j++)
    {
      printf("%d", mat[i][j]);
      if(j!=map_max-1)
        {
          printf(" ");
        }
    }
    printf("\n");
    }
}

C++: //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vvi G(n, vi(n));
    rep(i, n) {
        int oo;
        cin >> oo;
        int k;
        cin >> k;
        rep(i, k) {
            int s;
            cin >> s;
            G[oo-1][s-1] = 1;
        }
    }

    rep(i, n) {
        rep(j, n) {
            cout << G[i][j] << (j == n-1?'\n':' ');
        }
    }
}

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

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

C++: #include<iostream>
using namespace std;
int main(){
  int N;
  bool info[100][100] = {{}};
  cin >> N;
  for(int i = 0; i < N; i++){
    int u, k;
    cin >> u >> k;
    while(k--){
      int v;
      cin >> v;
      info[u - 1][v - 1] = true;
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      cout << info[i][j] << (j + 1 == N ? '\n' : ' ');
    }
  }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int M[101][101];
int main(){
  int n,u,k,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=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");
  }
  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++ )
    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;
  }

  return 0;
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <sstream>
#include <stdio.h>

using namespace std;

const int N_MAX = 1000000;

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

  // table
  int** table = new int*[N];
  for(int i=0; i<N; i++){
    table[i] = new int[N];
    memset(&table[i][0], 0, N*sizeof(table[i][0]));
    // &table[i][0] can be table[i] because it only needs head address.
    
    //[..., [int, int,int], ...]
    // memset(start_addr, 0, delta_arr) fills
    // start_addr to (start_addr + delta_arr) by 0.
    // table[i] refers to the first addr of table[i],
    // for each integer to be filled by 0, size of the element
    // (not table[i]) should be given.
  }
  
  for(int i=0; i<N; i++){
    int row_num, k;
    cin >> row_num >> k;

    row_num--;
    
    for(int j=0; j<k; j++){
      int col_num;
      cin >> col_num;
      col_num--;
      table[row_num][col_num] = 1;
    }
  }

  //print table
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cout << table[i][j] << " ";
    }
    cout << endl;
  }
  
  for(int i=0; i<N; i++){
    delete[] table[i];
  }
  delete[] table;
  
  return 0;
}

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

int graph[MAX_N+1][MAX_N+1];

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

  for(int i=1;i<=n;i++) {
    for(int j=1;j<=n;j++) {
      cout << graph[i][j] << (j==n ? "\n" : " ");
    }
  }
}