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

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

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

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

k = A("k")
a = B("a")
c = C("c")
d = D("d")
h = C("h")
e = A("e")
m = C("m")
i = D("i")
f = B("f")

k.s = m
k.y = m
a.x = m
a.w = k
c.r = e
c.x = d
c.u = h
d.z = m
h.r = e
h.x = d
h.u = m
e.s = m
e.y = h
m.r = e
m.x = i
m.u = c
i.z = c
f.x = h
f.w = k
assert a.w.s.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.y: C = None
        self.txt = txt

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

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

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

k = A("k")
a = B("a")
c = C("c")
d = D("d")
h = C("h")
e = A("e")
m = C("m")
i = D("i")
f = B("f")

k.s = m
k.y = m
a.x = m
a.w = k
c.r = e
c.x = d
c.u = h
d.z = m
h.r = e
h.x = d
h.u = m
e.s = m
e.y = h
m.r = e
m.x = i
m.u = c
i.z = c
f.x = h
f.w = k
assert a.w.s.u.u.u.txt == "m"