#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 105

enum Type{
	MIN,
	MAX,
};

int V;
int table[6][120][5];
int num_pattern[6],calc_array[6];
int value[NUM],num_child[NUM],child[NUM][5];
int map_index;
int dp[2][NUM][2*NUM][2*NUM];
map<int,int> MAP;
bool check[6],visited[NUM][2*NUM][2*NUM];


void makeTable(int max_num,int index){

	if(index == max_num){

		for(int i = 0; i < max_num; i++){
			table[max_num][num_pattern[max_num]][i] = calc_array[i]-1;
		}
		num_pattern[max_num]++;

		return;
	}

	for(int next_num = 1; next_num <= max_num; next_num++){

		if(check[next_num])continue;
		check[next_num] = true;
		calc_array[index] = next_num;
		makeTable(max_num,index+1);
		check[next_num] = false;
	}
}

void registMAP(int num){

	auto at = MAP.find(num);

	if(at == MAP.end()){
		MAP[num] = map_index++;
	}

	at = MAP.find(-num);

	if(at == MAP.end()){
		MAP[-num] = map_index++;
	}
}

void dfs(int node_id){

	if(num_child[node_id] == 0){

		return;
	}

	for(int i = 0; i < num_child[node_id]; i++){
		dfs(child[node_id][i]);
	}
	value[node_id] = -BIG_NUM;

	for(int i = 0; i < num_child[node_id]; i++){
		value[node_id] = max(value[node_id],-value[child[node_id][i]]);
	}
}

void recursive(int node_id,int A,int B){

	if(visited[node_id][MAP[A]][MAP[B]])return;

	visited[node_id][MAP[A]][MAP[B]] = true;

	if(num_child[node_id] == 0){
		dp[MIN][node_id][MAP[A]][MAP[B]] = 1;
		dp[MAX][node_id][MAP[A]][MAP[B]] = 1;
		return;
	}

	int tmp_A,tmp_B,tmp_child;
	int minimum = BIG_NUM,maximum = -BIG_NUM;
	int tmp_min,tmp_max,val;

	for(int i = 0; i < num_pattern[num_child[node_id]]; i++){

		tmp_min = 0;
		tmp_max = 0;
		tmp_A = A;
		tmp_B = B;

		for(int k = 0; k < num_child[node_id]; k++){

			tmp_child = child[node_id][table[num_child[node_id]][i][k]];
			recursive(tmp_child,-tmp_B,-tmp_A);

			val = -value[tmp_child];

			tmp_min += dp[MIN][tmp_child][MAP[-tmp_B]][MAP[-tmp_A]];
			tmp_max += dp[MAX][tmp_child][MAP[-tmp_B]][MAP[-tmp_A]];

			if(val >= tmp_B){
				break;
			}
			if(val > tmp_A){
				tmp_A = val;
			}
		}
		minimum = min(minimum,tmp_min);
		maximum = max(maximum,tmp_max);
	}
	dp[MIN][node_id][MAP[A]][MAP[B]] = minimum;
	dp[MAX][node_id][MAP[A]][MAP[B]] = maximum;

}

int main(){

	for(int i = 1; i <= 5; i++){
		num_pattern[i] = 0;
	}

	for(int max_num = 1; max_num <= 5; max_num++){

		for(int i = 1; i <= max_num; i++){
			check[i] = false;
		}
		for(int first_num = 1; first_num <= max_num; first_num++){
			check[first_num] = true;
			calc_array[0] = first_num;
			makeTable(max_num,1);
			check[first_num] = false;
		}
	}

	scanf("%d",&V);

	registMAP(BIG_NUM);

	for(int i = 0; i < V; i++){
		scanf("%d",&value[i]);
		registMAP(value[i]);
	}

	int tmp;
	for(int i = 0; i < V; i++){

		scanf("%d",&num_child[i]);

		for(int k = 0; k < num_child[i]; k++){
			scanf("%d",&tmp);
			tmp--;
			child[i][k] = tmp;
		}
	}

	for(int i = 0; i < V; i++){
		for(int k = 0; k < map_index; k++){
			for(int p = 0; p < map_index; p++){

				visited[i][k][p] = false;

				dp[MIN][i][k][p] = BIG_NUM;
				dp[MAX][i][k][p] = -BIG_NUM;
			}
		}
	}

	dfs(0);
	recursive(0,-BIG_NUM,BIG_NUM);

	printf("%d %d\n",dp[MIN][0][MAP[-BIG_NUM]][MAP[BIG_NUM]],dp[MAX][0][MAP[-BIG_NUM]][MAP[BIG_NUM]]);

	return 0;
}



Measured memory_bytes: 34492