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

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

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

j = A("j")
e = B("e")
m = C("m")
n = B("n")
b = C("b")

j.x = e
j.z = b
j.o = b
e.t = b
e.q = j
m.v = b
m.o = j
n.t = m
n.q = j
b.v = m
b.o = j
assert b.o.x.q.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: C = None
        self.o: C = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
m = C("m")
n = B("n")
b = C("b")

j.x = e
j.z = b
j.o = b
e.t = b
e.q = j
m.v = b
m.o = j
n.t = m
n.q = j
b.v = m
b.o = j
assert b.o.x.q.o.o.txt == "j"