class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

l = A("l")
m = B("m")
n = B("n")
i = B("i")
h = A("h")
c = A("c")
k = B("k")

l.t = i
m.q = l
n.q = l
i.q = c
h.t = n
c.t = i
k.q = h
assert n.q.t.q.t.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

l = A("l")
m = B("m")
n = B("n")
i = B("i")
h = A("h")
c = A("c")
k = B("k")

l.t = i
m.q = l
n.q = l
i.q = c
h.t = n
c.t = i
k.q = h
assert n.q.t.q.t.q.t.q.txt == "c"