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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.v: D = None
        self.z: C = None
        self.txt = txt

l = A("l")
h = B("h")
d = C("d")
c = D("c")
n = E("n")
j = A("j")

l.w = n
l.o = d
h.p = c
h.u = n
h.r = d
h.o = l
d.p = c
d.v = c
d.y = h
d.s = n
c.y = h
c.p = h
n.x = h
n.q = d
n.z = d
n.v = c
j.w = n
j.o = d
assert c.p.p.p.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: E = None
        self.o: C = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: B = None
        self.q: C = None
        self.v: D = None
        self.z: C = None
        self.txt = txt

l = A("l")
h = B("h")
d = C("d")
c = D("c")
n = E("n")
j = A("j")

l.w = n
l.o = d
h.p = c
h.u = n
h.r = d
h.o = l
d.p = c
d.v = c
d.y = h
d.s = n
c.y = h
c.p = h
n.x = h
n.q = d
n.z = d
n.v = c
j.w = n
j.o = d
assert c.p.p.p.r.s.txt == "n"