#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>
using namespace std;
int main(void) {
      int pid;
      for (int i=0;i<3;i++) {
           pid=fork();
           if (pid==0) break;
           }
      if (pid==0) {
           cout << "child:" << getpid() << endl;
     } else {
             cout << "parent:" << getpid() << endl;
             for (int i=0;i<3;i++)
             wait(NULL);
       }
      return 0;
}
