using System;
using System.Collections.Generic;
public class Graph
{
private int V;
private List<int>[] adj;
private SortedDictionary<int, int> adj2;
public Graph(int V)
{
this.V = V;
adj = new List<int>[V];
for (int i = 0; i < V; i++)
adj[i] = new List<int>();
adj2 = new SortedDictionary<int, int>();
}
public void addEdges()
{
foreach (KeyValuePair<int, int> x in adj2)
{
adj[x.Key].Add(x.Value);
adj[x.Value].Add(x.Key);
}
}
public void removeEdges(int V, int[,] Edges, int E, int[] queries, int Q)
{
SortedDictionary<int, int> adj3 = new SortedDictionary<int, int>();
for (int i = 0; i < E; i++)
adj3[Edges[i, 0]] = Edges[i, 1];
for (int i = 0; i < Q; i++)
adj3.Remove(queries[i]);
foreach (KeyValuePair<int, int> it in adj3)
adj2[it.Value] = it.Key;
for (int i = 0; i < Q; i++)
adj2.Remove(queries[i]);
}
public int NumberOfconnectedComponents()
{
bool[] visited = new bool[V];
int count = 0;
for (int v = 0; v < V; v++)
visited[v] = false;
for (int v = 0; v < V; v++)
{
if (!visited[v])
{
cnt = 0;
DFSUtil(v, visited);
count += 1;
}
}
return count;
}
public int maxLen = 0;
public int cnt;
public void DFSUtil(int v, bool[] visited)
{
visited[v] = true;
cnt++;
foreach (int i in adj[v])
{
if (!visited[i])
DFSUtil(i, visited);
}
maxLen = Math.Max(maxLen, cnt);
}
}
public class Program
{
public static void Main()
{
int V = 7, E = 6;
Graph g = new Graph(V);
int[,] Edges = { { 0, 3 }, { 1, 5 }, { 3, 6 }, { 3, 2 }, { 2, 4 }, { 5, 6 } };
int Q = 1;
int[] queries = { 3 };
g.removeEdges(V, Edges, E, queries, Q);
g.addEdges();
Console.WriteLine(g.NumberOfconnectedComponents() - Q + " " + g.maxLen);
}
}