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

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: D = None
        self.v: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
c = C("c")
l = D("l")
a = D("a")
h = A("h")
e = D("e")
d = D("d")

m.x = i
i.z = c
i.s = c
i.y = m
i.o = h
c.o = m
c.r = a
c.v = h
l.u = c
a.u = c
h.x = i
e.u = c
d.u = c
assert c.r.u.o.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: A = None
        self.r: D = None
        self.v: A = None
        self.txt = txt

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

m = A("m")
i = B("i")
c = C("c")
l = D("l")
a = D("a")
h = A("h")
e = D("e")
d = D("d")

m.x = i
i.z = c
i.s = c
i.y = m
i.o = h
c.o = m
c.r = a
c.v = h
l.u = c
a.u = c
h.x = i
e.u = c
d.u = c
assert c.r.u.o.x.y.x.txt == "i"