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

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

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

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

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

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

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

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

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

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

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