Help me in solving CAESAR problem

My issue

This code is throwing WA for test cases except the given sample input/output of the question. I don’t see any issue with my code here.

My code

import sys, math
from sys import stdin
from collections import Counter

# ASCII for characters A-Z : 65-90 && a-z : 97-122
ti = lambda : int(input())
tl = lambda : list(map(int, input().split()))
ts = lambda : input()

mod = 10**9+7
sys.setrecursionlimit(10**6)

def solve():
    ans = ""
    n = int(input())
    string = []
    for i in range(3):
        string.append(input())

    k = ord(string[1][0]) - ord(string[0][0])
    
    for i in range(n):
        temp = ord(string[2][i]) + abs(k)
        if temp > 122:
            temp -= 26
        ans += chr(temp)

    print(ans)

def main():
    for _ in range(ti()):
        solve()

if __name__ == "__main__":
    main()

Problem Link: CAESAR Problem - CodeChef

@shubhamraj1603
Try for test case
1
1
b
a
a
Your code is giving b as answer but it would be z.
u have to tackle negative values of k separately as well.