class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: A = None
        self.o: 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: C = None
        self.w: A = None
        self.p: B = None
        self.txt = txt

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

j.t = b
j.q = m
j.o = i
b.t = m
c.z = i
c.w = j
c.p = b
m.t = b
m.q = j
m.o = i
f.t = m
i.z = c
i.w = m
i.p = f
assert i.p.t.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.q: A = None
        self.o: 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: C = None
        self.w: A = None
        self.p: B = None
        self.txt = txt

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

j.t = b
j.q = m
j.o = i
b.t = m
c.z = i
c.w = j
c.p = b
m.t = b
m.q = j
m.o = i
f.t = m
i.z = c
i.w = m
i.p = f
assert i.p.t.q.o.txt == "i"