ساعت
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ساعت
دقیقه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
دقیقه
ثانیه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ثانیه
  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

It will be the greatest event of all times, yes… you’ve guessed right… it’s SHAMIR’S BIRTHDAY PARTYYYY!!!

توضیح تصویر

But unfortunately, Shamir is very lonely and he is not in a party mood right now, poor Shamir. So he wants to invite as minimum of his friends as possible (at least one!) as long as no one gets sad. One would get sad if he/she misses someone. Yes as you’ve realized this problem is also love-related. So if Shamir invites a person, he has to invite all of his/her crushes too.

  • “what a b****** p*** a** ”, Shamir said.

You, as a genius programmer (like AmirShams) should help Shamir Figure it out. you will be given the crushes-list of every person that possibly can come to party. You should determine what’s the minimum number of people Shamir should invite so that no one during the party get upset and miss some other bastards. So help Shamir! (Remember, Shamir has to invite someone)

ورودی

The first line of input shows the number of test cases TT. 1T101 \leq T \leq 10

Each test case contains two space separated integers NN and MM indicating Shamir’s friends (and their friends too) and number of crushes lists respectively and is followed by MM lines. 1N,M100,0001 \leq N, M \leq 100 , 000

Each of following MM lines there will be two integers UU and VV indicating UU has a crush over VV. 1UVN1 \leq U \neq V \leq N

Shamir friends are weird like him. don’t care about his friends genders. so Triangle-love is possible!

خروجی

For each test case, print the minimum number of Shamir’s friends that should come to the party so that anyone will have a good time in the party (and possibly outside the party).

مثال‌ها

ورودی نمونه ۱

1
4 4
1 2
2 4
4 1
2 3
Plain text

خروجی نمونه ۱

1
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.