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

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

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

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

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

l.p = m
l.r = d
m.r = h
i.y = m
i.o = m
i.q = a
i.s = d
h.w = l
h.u = k
c.w = l
c.u = h
f.w = d
f.u = c
d.p = m
d.r = l
k.w = l
k.u = h
a.y = m
a.o = m
a.q = i
a.s = l
assert i.q.s.p.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.r: A = None
        self.txt = txt

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

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

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

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

l.p = m
l.r = d
m.r = h
i.y = m
i.o = m
i.q = a
i.s = d
h.w = l
h.u = k
c.w = l
c.u = h
f.w = d
f.u = c
d.p = m
d.r = l
k.w = l
k.u = h
a.y = m
a.o = m
a.q = i
a.s = l
assert i.q.s.p.r.w.txt == "l"