Stuck on this question explanation need help

Two teams were playing (soccer) match and the record events for each team is available. There are 4 possible events, Goal(G), Yellow Card (Y), Red Card ® and Substitution. The first three events (G, Y, R) are represented as player-name time eevnt-name whereas the last event (S) is represented as player-name time event-name second-player-name. This time is represented in minutes from the start of the game. A football game is divided into two halves of 45 minutes each, and sometimes a little extra time is given at the end of each half, which is represented in the time as time+extra-time. So there can be two types of times, for example, 32 and 45+2. The extra time is always considered to have occured before the events of the next half, so 45+2, happened earlier than 46.

Merge the events for each team into a single game event with teams name in front and sorted by time and event in order of G, Y, R. In this case of the same event happening at the same time, output should be sorted lexicographically based on teams name and players name.

Take for example, the first team 1 = “EDC” with events recorded as events1 = [‘Name1 12 G’, ‘FirstName LastName 43 Y’] and second team team2 = “CDE” with events recorder as events2 = [‘Name3 45+1 S SubName’, ‘Name4 46 G’], then the chronological order of events is given by:

EDC Name1 12 G
EDC FirstName LastName 43 Y
CDE Name3 45+1 S SubName
CDE Name 46 G

Function description:
getEventsOrder has the following paramters:
team1: a string, the name of first team
team2: s string, the name of second team
events1[events1[0]…events[n-1]]: an array of strings that describe the events of the first team

events2[events2[0]…events2[n-1]]: an array of strings that describe the events of the second team

Constraint:
0<length of events1, events2 <= 20
0<length of team’s name <= 50
0< length of player’s name <= 50
Time will be between 0 and 90 and extra time will always be written after +

The first line contains a string, the name of team1.

The second line contains a string, the name of team2

The next line contains an integer n1,the number of elements in events1

Each line i of the n1 subsequent lines (where 0<= i <= n1) contains a string that describe events1[i].

The next line contains an integer, n2, denoting the number in events2.

Each time j of the n2 subsequent lines (where 0<=j <= n2) contains a string that describe events2[i].

Same Input:
ABC
CBA
2
Mo Sa 45+2 Y
A 13 G
D 23 S F
Z 46 G

Sample Output:
ABC A 13 G
CBA D 23 S F
ABC Mo Sa 45+2 Y
CBA Z 46 G

Explanation:
The first event happens at 13th minute (G), then the next event happens at 23rd minute (S), next one at 45+2nd minute (Y), and the last event at 46th minute (G).

Can anyone provide me a simpler explanation,code or approach if possible??