class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: C = None
        self.txt = txt

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

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

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

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

m.u = b
m.s = b
c.x = m
c.w = m
c.q = m
c.u = j
b.r = f
b.q = j
f.x = b
f.w = b
f.z = m
f.p = m
j.x = m
j.w = m
j.q = m
j.u = c
assert m.u.q.u.w.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.s: C = None
        self.txt = txt

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

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

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

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

m.u = b
m.s = b
c.x = m
c.w = m
c.q = m
c.u = j
b.r = f
b.q = j
f.x = b
f.w = b
f.z = m
f.p = m
j.x = m
j.w = m
j.q = m
j.u = c
assert m.u.q.u.w.s.txt == "b"