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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: D = None
        self.txt = txt

l = A("l")
g = B("g")
c = C("c")
i = D("i")
n = E("n")

l.p = i
l.q = c
g.o = n
g.q = c
c.y = i
c.r = i
c.w = g
i.u = c
n.v = i
n.s = i
assert g.q.y.u.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.s: D = None
        self.txt = txt

l = A("l")
g = B("g")
c = C("c")
i = D("i")
n = E("n")

l.p = i
l.q = c
g.o = n
g.q = c
c.y = i
c.r = i
c.w = g
i.u = c
n.v = i
n.s = i
assert g.q.y.u.w.o.txt == "n"