I am writing a function to match elements of a tuple (G) using if, elif conditions. The tuple G is a 10 by 3 tuple. G[0] is information of student ‘S1’ with supervisor ‘SP1’ and panel ‘P1’ which consists of three members.

The data structure is as follows:

```
[('S1', 'A8', ('A1', 'A2', 'A3')), ('S2', 'A5', ('A1', 'A2', 'A3')), ('S3', 'A6', ('A3', 'A4', 'A5')), ('S4', 'A1', ('A6', 'A7', 'A8')), ('S5', 'A4', ('A6', 'A7', 'A8')), ('S6', 'A2', ('A9', 'A10', 'A11')), ('S7', 'A3', ('A8', 'A9', 'A10')), ('S8', 'A4', ('A12', 'A13', 'A10')), ('S9', 'A10', ('A12', 'A13', 'A14')), ('S10', 'A11', ('A12', 'A13', 'A7'))]
```

The definition of the match matrix is:

- “0” means there is no conflict between the student panels. This means students can be allocated into the same timeslot on the same day but must be in different rooms. So, for example, S1, S8, S9 and S1 have no conflict with each other.
- “1” indicates there is a conflict between the student panels. This is because they have at least one common panel member. So these students can not be allocated into the same timeslot on the same day. For example, S1, S2 and S3 have common panel members, so they conflict with each other.
- “ 1* ” indicates the students’ conflict with each other in terms of both panels and supervisors. So these students can not be allocated into the same timeslot on the same day. For example, the S2 supervisor is a panel member of S3.
- “*” indicates students’ conflict with each other in term supervisor only. In this case, these students can be allocated into the same timeslot on the same day in different rooms, but plenty will be added to the timetable quality.
- The total of conflicts column shows the number of conflicts in each row. For example, S1 has 2 conflicts, S2 has 2 conflicts, S3 has 2 conflicts, and so on.

I am having trouble finding a way to match the elements based on the given definitions and print a matrix:

Tried code:

```
def matrix_generator(D1,D2,Match1):
for i in range(len(D1)):
for j in range(len(D2)):
if D1[2][i] != D2[2][j] and (D1[1] == D2[2][j]) or (D2[1] == D1[2][j]):
Match1[i][j] = "*"
if D1[2][i] == D2[2][j]:
Match1[i][j] = "1"
elif (D1[1] == D2[2][j]) or (D2[1] == D1[2][j]) and (D1[2][i] != D2[2][j]):
Match1[i][j] = "*1"
return Match1
Match1 = [[0 for i in range(10)] for j in range(10)]
for i in range(0,9):
for j in range(0,9):
aa= matrix_generator(G[i],G[j], Match1)
print(aa)
```

I am getting output:

```
[['1', '*1', '*1', 0, 0, 0, 0, 0, 0, 0], ['1', '1', '*1', 0, 0, 0, 0, 0, 0, 0], ['*1', '*1', '1', 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
```

The desired output is

Can someone please explain how it can be done?