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

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

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

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

f = A("f")
j = B("j")
m = C("m")
b = D("b")
c = A("c")
k = B("k")
a = B("a")
h = A("h")
d = A("d")
g = A("g")

f.w = m
j.v = b
m.r = j
m.w = a
m.s = a
m.x = k
b.u = k
b.s = c
c.w = m
k.v = b
a.v = b
h.w = m
d.w = m
g.w = m
assert f.w.x.v.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

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

f = A("f")
j = B("j")
m = C("m")
b = D("b")
c = A("c")
k = B("k")
a = B("a")
h = A("h")
d = A("d")
g = A("g")

f.w = m
j.v = b
m.r = j
m.w = a
m.s = a
m.x = k
b.u = k
b.s = c
c.w = m
k.v = b
a.v = b
h.w = m
d.w = m
g.w = m
assert f.w.x.v.s.w.txt == "m"