Go: package main

/*
グラフの表現 隣接行列による表現
*/

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
		ints := eGetInts(scanner)
		num := ints[0]
		for j := 0; j < ints[1]; j++ {
			g[num-1][ints[j+2]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		s := fmt.Sprint(g[i])
		fmt.Println(s[1 : len(s)-1])
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}

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

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

int main()
{
  int n;
  cin >> n;
  vector<vector<int> > G(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;
      G.at(u - 1).at(v - 1) = 1;
    }
  }

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      cout << G.at(i).at(j);
      if (j == n - 1)
      {
        cout << endl;
      }
      else
      {
        cout << " ";
      }
    }
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int a[101][101];
	int n,u,k,x;
	memset(a,0,sizeof(a));
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>u>>k;
		while (k--){
			  cin>>x;
			  a[u][x]=1;
		}
	}
	for (int i=1; i<=n; i++){
		cout<<a[i][1];
		for (int j=2; j<=n; j++)
		    cout<<' '<<a[i][j];
		cout<<'\n';
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n; cin>>n;
    vector<vector<int>> v(n,vector<int>(n,0));
    rep(i,0,n){
        int u,k;
        cin>>u>>k;
        rep(j,0,k){
            int x;
            cin>>x;
            v[u-1][x-1]=1;
        }
    }
    
    rep(i,0,n){
        rep(j,0,n){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
    
    return 0;
}