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

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
a = C("a")
j = D("j")
e = B("e")
m = B("m")

c.o = b
c.q = m
b.w = j
b.s = c
b.v = m
a.z = j
a.x = j
a.u = e
j.z = e
e.w = j
e.s = c
e.v = b
m.w = j
m.s = c
m.v = e
assert e.w.z.w.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: D = None
        self.s: A = None
        self.v: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
a = C("a")
j = D("j")
e = B("e")
m = B("m")

c.o = b
c.q = m
b.w = j
b.s = c
b.v = m
a.z = j
a.x = j
a.u = e
j.z = e
e.w = j
e.s = c
e.v = b
m.w = j
m.s = c
m.v = e
assert e.w.z.w.z.s.txt == "c"