Here I am going to share with you my codes related to **Challenge Problem**. I am facing a problem that i had written two codes and one is a special case of second but i am getting more marks in the special case.

so please help me.

in the first code, I had implemented this method.

I am going to answer questions from 1 to n and answer it such that I increase the score of a maximum number of the question form which has a minimum score.

actually I am storing every form score in a separate array.

And other one instead of going questionwise I am just calculating frequency such that I increase the score of a maximum number of the question form which has a minimum score.

As you can see first one in one way is one of the case of second but I am getting more points in the first one then the second so please help me.

do I do some mistake in the second code implementation

- First code

```
from random import randint
t = int(input())
for _ in range(t):
[n,m,k] = list(map(int,input().split()))
c = []
for i in range(n):
c.append(list(map(int,input().split())))
score = [0 for i in range(k)]
output = []
for i in range(n):
minimum = min(score)
mydict = {}
for j in range(k):
if(score[j]==minimum):
try:
mydict[c[i][j]][0] += 1
except KeyError:
mydict[c[i][j]] = [1,0]
for j in range(k):
try:
mydict[c[i][j]][1]+=1
except KeyError:
pass
value = sorted(mydict,key=lambda x: (mydict[x][0],mydict[x][1]))[-1]
output.append(value)
for j in range(k):
if(c[i][j] == value):
score[j]+=1
for i in range(n):
print(output[i],end=" ")
print()
```

- Second code

```
t = int(input())
for _ in range(t):
[n,m,k] = list(map(int,input().split()))
c = []
for i in range(n):
c.append(list(map(int,input().split())))
score = [0 for i in range(k)]
output = [0 for i in range(n)]
checked = [True for i in range(n)]
for i in range(n):
minimum = min(score)
listofminimum = [j for j in range(k) if score[j]==minimum]
maximumFrequancy = 0
option = 0
question = 0
mydict = {}
#question number j
for j in range(n):
if(checked[j]):
for p in listofminimum:
try:
#first index of c is question and second is sheet number
#first index of mydict is option for a perticular question
mydict[c[j][p]] +=1
except KeyError:
mydict[c[j][p]] =1
nowoption = max(mydict, key=mydict.get)
nowfrequency = mydict[nowoption]
if(nowfrequency>maximumFrequancy):
option = nowoption
maximumFrequancy = nowfrequency
question = j
checked[question] = False
output[question] = option
for j in range(k):
if(c[question][j]==option):
score[j]+=1
for i in range(n):
print(output[i],end=" ")
print()
```