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

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

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

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

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

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

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

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

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

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

e.r = i
e.z = i
e.p = f
d.x = e
k.u = d
k.w = c
f.w = b
f.s = i
m.u = d
m.w = k
i.r = e
i.z = e
i.p = f
c.u = d
c.w = m
b.u = d
b.w = c
assert c.u.x.z.p.s.txt == "i"