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

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

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

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

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

d.y = e
d.x = c
b.r = e
b.y = e
m.q = i
m.t = l
a.y = e
a.o = i
l.y = e
l.o = a
e.r = b
e.y = b
i.y = b
i.o = l
c.y = b
c.x = d
n.q = i
n.t = a
assert m.t.o.y.r.r.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.x: A = None
        self.txt = txt

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

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

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

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

d.y = e
d.x = c
b.r = e
b.y = e
m.q = i
m.t = l
a.y = e
a.o = i
l.y = e
l.o = a
e.r = b
e.y = b
i.y = b
i.o = l
c.y = b
c.x = d
n.q = i
n.t = a
assert m.t.o.y.r.r.y.r.txt == "e"