Why this code is not working for all the input?

Here is the question

The first line contains the string s which Steve Jobs’ ghost types. The second line contains an integer n (1<=n<=100) which is the number of words in the dictionary. Then follow n lines which are the words on the dictionary, one on each line. All the lines have lengths of 1 to 100 characters inclusively, and consist of lowercase English letters only.

Output

If s is not the beginning of any of n words in the dictionary, print s. Otherwise, print the lexicographically lowest word beginning with s.

The lexicographical order is the order of words in a dictionary.

Sample test(s)

Input

next 2 nextpermutation nextelement

Output

nextelement

Here is my Code

int main()
{
  char wo[30],fs[30],dic[100][30];
  int mt[100],dicln[100];
  int i, cnt, wordc,k=0,j,temp,x,t1;
  scanf("%s",wo);
  scanf("%d",&cnt);
  wordc = strlen(wo);


  for(i = 0 ; i < cnt; i++)
  {
     scanf("%s",dic[i]);

   if(strncmp(dic[i],wo,wordc) == 0)
  {
    mt[k] = i;
     k++;

  }
 } 
temp = mt[0];
strcpy(fs, dic[temp]);

for(i = 0; i < k-1; i ++)
{
  temp = mt[i];

  if(strlen(dic[temp+1]) == strlen(dic[temp]))
  {

    for(j = wordc+1; j <= strlen(dic[temp]) ; j++)
    {
     t1 = strncmp(dic[temp+1],dic[temp],j);
     if(t1 < 0 )
        strcpy(fs, dic[temp+1]);
    }

   }
    else if(strlen(dic[temp+1]) < strlen(dic[temp]))
  { 

   strcpy(fs, dic[temp+1]);
  }
  } 

 if(k == 0)
    printf("%s",wo);
 else
    printf("%s",fs);
 return 0;
}

For this output I got 70 out of 100. So I want to know for which input the code will fail.

I don’t need new code, just need modification in my code for those input.

Thanks in adv.

//