Go: package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	for i := 0; i < num; i++ {
		sc.Scan()
		sc.Text()
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		r := make([]int, num)
		for j := 0; j < num2; j++ {
			sc.Scan()
			val, _ := strconv.Atoi(sc.Text())
			r[val-1] = 1
		}
		for i, v := range r {
			if i != 0 {
				fmt.Printf(" %v", v)
			} else {
				fmt.Printf("%v", v)
			}
		}
		fmt.Println()
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>

using namespace std;

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

    int n;scanf("%d",&n);
    int u;
    int k;
    vector<vector<int> > graph;
    graph.resize(n);
    for(int i=0;i<n;i++){
        graph[i].resize(n);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            graph[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        int value;
        for(int j=0;j<k;j++){
            scanf("%d",&value);
            graph[u-1][value-1]=1;
        }
    }

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

    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
    int n,u,k,v;
    cin >> n;
    vector<vector<int>>M(n,vector<int>(n));
    rep(i,n) {
        rep(j,n) {
            M[i][j] = 0;
        }
    }
    rep(i,n) {
        cin >> u >> k;
        u--;
        rep(j,k) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }

    rep(i,n) {
        rep(j,n) {
            cout << M[i][j];
            if(j != n-1) cout <<" ";
        }
        cout << endl;
    }
    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; //在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++: //ALDS1_11A
#include <iostream>
#include <vector>
using namespace std;

int main(){
 int n,u,k,v;
 cin>>n;
 vector< vector<bool> > M(n,vector<bool>(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]=true;
  }
 }

 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 <stdio.h>

#define MAX 100

int main() {
    int n;
    int M[MAX][MAX];
    scanf("%d", &n);
    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++) {
        int id, k;
        scanf("%d %d", &id, &k);
        if (k == 0) continue;
        else {
            for (int j = 1; j <= k; j++) {
                int v; scanf("%d", &v);
                M[id][v] = 1;
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j == n) printf("%d\n", M[i][j]);
            else printf("%d ", M[i][j]);
        }
    }
    
    return 0;
}

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

class Graph
{
  public:
    Graph(int n);

    void Show() const;

  private:
    vector<vector<int>> m_graph;
};

Graph::Graph(int n) :
  m_graph(n, vector<int>(n, 0))
{
  for (int i = 0; i < n; ++i)
  {
    int u, k;
    cin >> u >> k;
    vector<int> list(k);
    for (int j = 0; j < k; ++j)
    {
      cin >> list[j];
    }

    for (auto v : list)
    {
      m_graph[u-1][v-1] = 1;
    }
  }
}

void Graph::Show() const
{
  for (auto a: m_graph)
  {
    for (auto b : a)
    {
      cout << b << " ";
    }
    cout << endl;
  }
}

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

  Graph graph(n);
  graph.Show();
  return 0;
}

C++: #include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll d[100][100];
	REP(i, n) REP(j, n) d[i][j] = 0;
	REP(i,n)
	{
		cin >> w >> k;
		REP(j, k) {
			cin >> h;
			d[i][h - 1] = 1;
		}
	}
	
	REP(i, n) {
		REP(j, n)
		{
			cout << d[i][j] << ' ';
		}
		cout << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define vector_rsort(x) sort(all(x));reverse(all(x))
#define array_rsort(x,n) sort(x,x+n);reverse(x,x+n);
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,u,k,v;
int g[105][105];

int main(){
  scanf("%d",&n);

  rep(i,n){
    scanf("%d%d",&u,&k);
    rep(i,k){
      scanf("%d",&v);
      g[u][v]=1;
    }
  }
  
  REP(i,1,n+1){
    REP(j,1,n+1){
      printf("%d ",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n,u[100],k[100]={},v[100][100];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> u[i];
    int x;
    cin >> x;
    k[u[i]-1]+=x;

    for(int j=0; j<k[i]; j++)
      cin >> v[i][j];
  }

  for(int i=0; i<n; i++){
    int count=0;
    for(int j=0; j<n; j++){
      if(v[i][count]==j+1){
        cout << 1;
        count++;
      }

      else
        cout << 0;

      if(j!=n)
        cout << " ";
      }

      cout << endl;
    }
  }