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

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.o: A = None
        self.q: B = None
        self.txt = txt

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

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

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

m.t = e
e.z = d
e.v = d
e.o = k
e.q = f
b.o = e
b.p = d
i.u = h
d.t = e
h.o = f
h.p = k
k.t = e
a.t = e
f.z = k
f.v = a
f.o = a
f.q = e
c.t = e
assert i.u.o.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: A = None
        self.v: A = None
        self.o: A = None
        self.q: B = None
        self.txt = txt

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

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

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

m.t = e
e.z = d
e.v = d
e.o = k
e.q = f
b.o = e
b.p = d
i.u = h
d.t = e
h.o = f
h.p = k
k.t = e
a.t = e
f.z = k
f.v = a
f.o = a
f.q = e
c.t = e
assert i.u.o.q.v.txt == "d"