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

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

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

g = A("g")
j = B("j")
i = C("i")
h = A("h")
m = B("m")
f = A("f")
c = B("c")

g.o = i
g.z = i
j.t = i
i.p = j
i.o = g
h.o = i
h.z = i
m.t = i
f.o = i
f.z = i
c.t = i
assert j.t.p.t.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.txt = txt

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

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

g = A("g")
j = B("j")
i = C("i")
h = A("h")
m = B("m")
f = A("f")
c = B("c")

g.o = i
g.z = i
j.t = i
i.p = j
i.o = g
h.o = i
h.z = i
m.t = i
f.o = i
f.z = i
c.t = i
assert j.t.p.t.p.txt == "j"