fork download
  1. for _ in range(int(input())):
  2. s=input()
  3. hrs,mins=s.split(':')
  4. amPm=''
  5. if int(hrs)<=12:
  6. if int(hrs)==0:
  7. rem=12
  8. else:
  9. rem=int(hrs)
  10. else:
  11. rem=int(hrs)%12
  12. amPm=' AM' if int(hrs)<12 else ' PM'
  13. if len(str(rem))==1:
  14. x='0'+str(rem)
  15. else:
  16. x=str(rem)
  17. print(x+':'+mins+amPm)
  18.  
  19.  
  20.  
Success #stdin #stdout 0.04s 9868KB
stdin
11
09:41
18:06
12:14
00:59
00:00
14:34
01:01
19:07
11:59
12:00
21:37
stdout
09:41 AM
06:06 PM
12:14 PM
12:59 AM
12:00 AM
02:34 PM
01:01 AM
07:07 PM
11:59 AM
12:00 PM
09:37 PM