class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: C = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

l.y = m
l.t = n
l.p = a
l.s = d
m.r = e
m.o = a
i.u = e
i.o = d
i.q = l
d.w = i
j.y = e
j.t = i
j.p = i
j.s = d
e.r = m
e.o = a
n.u = m
n.o = d
n.q = l
a.u = m
a.o = d
a.q = l
assert d.w.q.p.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: C = None
        self.p: C = None
        self.s: D = None
        self.txt = txt

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

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

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

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

l.y = m
l.t = n
l.p = a
l.s = d
m.r = e
m.o = a
i.u = e
i.o = d
i.q = l
d.w = i
j.y = e
j.t = i
j.p = i
j.s = d
e.r = m
e.o = a
n.u = m
n.o = d
n.q = l
a.u = m
a.o = d
a.q = l
assert d.w.q.p.o.w.txt == "i"