using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication8
{
class Arcs
{
int[] heads;
int[] destination;
int[] nextArc;
public Arcs(int n, int m, int[] from, int[] to)
{
heads = new int[n];
destination = new int[m];
nextArc = new int[m];
for(int i = 0; i < heads.Length; ++i)
{
heads[i] = -1;
}
for(int i = 0; i < m; ++i)
{
AddArc(from[i], to[i], i);
}
}
public void AddArc(int from, int to, int i)
{
nextArc[i] = heads[from];
destination[i] = to;
heads[from] = i;
}
public void viewArcs(int from)
{
int j;
for(int i = heads[from]; i != -1; i = nextArc[i])
{
j = destination[i];
Console.Write("{0} ", j);
}
}
}
class Program
{
static void Main(string[] args)
{
int n = 6, m = 5;
int[] from = new int []{ 0,0,0,0,0 };
int[] to = new int []{ 1, 2, 3, 4, 5 };
Arcs arcs = new Arcs(n,m, from, to);
arcs.viewArcs(0);
}
}
}