A graph without loops or multiple edges is known as a simple graph.
A vertex-colouring is an assignment of colours to each vertex of a graph.
A proper vertex-colouring is a vertex-colouring in which no edge connects two identically coloured vertices.
A vertex-colouring with $n$ colours of an undirected simple graph is called an $n$-rainbow colouring if every colour appears once, and only once, on all the adjacent vertices of each vertex.
Note that an $n$-rainbow colouring is not a proper colouring, since adjacent vertices may share the same colour.
An undirected simple graph is called an $n$-rainbow graph if the graph can admit at least one legal $n$-rainbow colouring.
Two $n$-rainbow graphs $G$ and $H$ are called isomorphic if, between the sets of vertices in $G$ and $H$, a bijective mapping $f: V(G) \to V(H)$ exists such that two vertices in $G$ are adjacent if and only if their images in $H$ are adjacent.
Your task in this problem is to count the number of distinct non-isomorphic $n$-rainbow graphs having $2 n$ vertices and report that number modulo a prime number $p$.