Finding Profession
Submissions: 5007   Accuracy:


  Difficulty: Easy   Marks: 2

Consider a special family of Engineers and Doctors with following rules :

  1. Everybody has two children.
  2. First child of an Engineer is an Engineer and second child is a Doctor.
  3. First child of an Doctor is Doctor and second child is an Engineer.
  4. All generations of Doctors and Engineers start with Engineer.

We can represent the situation using below diagram:

           /        \
          E          D
        /   \       /  \
       E     D     D    E
      / \   / \   / \   / \
     E   D D   E  D  E  E  D

Given level and position of a person in above ancestor tree, find profession of the person.


Input : level = 4, pos = 2
Output : Doctor

Input : level = 3, pos = 4
Output : Engineer


First line of input contains number of test cases T. Each test case will be of one line. Each test case will have two space separated integers. First input represents Generation and second input represents child number.

Corresponding to each test case you have to print Doctor or Engineer in new line,based on input.

4 2
3 4



** For More Input/Output Examples Use 'Expected Output' option **

Author: mabhinav

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.