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

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

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

j = A("j")
h = B("h")
k = C("k")
c = A("c")
f = C("f")
l = B("l")
a = A("a")

j.s = k
j.q = a
h.z = c
k.t = f
c.s = k
c.q = a
f.t = k
l.z = c
a.s = k
a.q = c
assert k.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: A = None
        self.txt = txt

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

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

j = A("j")
h = B("h")
k = C("k")
c = A("c")
f = C("f")
l = B("l")
a = A("a")

j.s = k
j.q = a
h.z = c
k.t = f
c.s = k
c.q = a
f.t = k
l.z = c
a.s = k
a.q = c
assert k.t.t.t.t.t.t.t.txt == "f"