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

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

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

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

i = A("i")
h = B("h")
g = C("g")
d = D("d")
b = D("b")
m = C("m")
k = A("k")
n = C("n")

i.y = k
i.u = h
h.x = g
h.r = b
g.p = i
g.x = m
d.z = m
d.v = h
b.z = m
b.v = h
m.p = k
m.x = g
k.y = i
k.u = h
n.p = i
n.x = m
assert m.x.p.u.r.z.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: B = None
        self.txt = txt

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

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

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

i = A("i")
h = B("h")
g = C("g")
d = D("d")
b = D("b")
m = C("m")
k = A("k")
n = C("n")

i.y = k
i.u = h
h.x = g
h.r = b
g.p = i
g.x = m
d.z = m
d.v = h
b.z = m
b.v = h
m.p = k
m.x = g
k.y = i
k.u = h
n.p = i
n.x = m
assert m.x.p.u.r.z.x.x.txt == "m"