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

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

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

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

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

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

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

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

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

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

e.p = d
d.x = e
d.u = e
d.r = e
d.s = i
m.u = i
m.v = e
a.q = d
a.v = d
a.o = m
a.y = e
i.q = d
i.v = d
i.o = m
i.y = e
assert m.u.o.u.txt == "i"