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

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

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

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

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

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

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

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

h.o = c
h.q = i
l.t = h
k.z = c
i.z = c
j.o = l
j.q = k
c.t = j
assert k.z.t.q.z.t.q.txt == "k"