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

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

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

j = A("j")
m = B("m")
l = C("l")
n = C("n")
d = C("d")

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

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

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

j = A("j")
m = B("m")
l = C("l")
n = C("n")
d = C("d")

j.z = d
j.v = m
j.q = l
m.w = n
m.x = j
l.w = j
l.z = d
l.o = m
n.w = j
n.z = l
n.o = m
d.w = j
d.z = n
d.o = m
assert n.o.w.w.q.z.txt == "d"