Record the out-degree and in-degree of each side input.
Then traverse the in-degree of each point, store the points whose in-degree is zero into the queue, and set the f (the number of food chains array) corresponding to the point whose in-degree is zero to 1.
Then start to perform BFS on the queue and update the number of food chains at the point at the same time. Finally, when the in and out degree of a point is 0, the number of food chains is recorded in ans.