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

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

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

f = A("f")
m = B("m")
i = C("i")
h = A("h")
l = C("l")
k = C("k")
b = B("b")

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

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

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

f = A("f")
m = B("m")
i = C("i")
h = A("h")
l = C("l")
k = C("k")
b = B("b")

f.z = b
m.o = i
m.q = i
i.t = f
h.z = m
l.t = f
k.t = h
b.o = l
b.q = i
assert f.z.q.t.z.o.t.z.txt == "b"