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

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

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

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

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

m.v = f
n.x = h
h.z = m
h.t = d
d.u = f
d.x = h
d.s = a
i.u = f
i.x = h
i.s = a
e.x = h
f.v = m
a.u = f
a.x = h
a.s = i
assert d.s.u.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

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

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

m.v = f
n.x = h
h.z = m
h.t = d
d.u = f
d.x = h
d.s = a
i.u = f
i.x = h
i.s = a
e.x = h
f.v = m
a.u = f
a.x = h
a.s = i
assert d.s.u.v.v.v.v.v.txt == "m"