#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
srand(time(0));
int year = 365;
int people = 0;
int daycnt = 0;
bool found[year] = {false};
while(daycnt<year){
people++;
int birthday = (int)(rand() % year+1);
cout<<birthday<<endl;
if (found[birthday] == true){
daycnt++;
cout<<"When the "<<people<<"th person entered the room, a pair had matching birthdays."<<endl;
break;}
found[birthday] = true;
}
}