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

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

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

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

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

l = A("l")
c = B("c")
j = C("j")
h = D("h")
e = E("e")
b = D("b")

l.p = c
l.s = c
l.y = b
l.q = j
c.s = l
j.y = e
j.q = l
h.q = c
h.w = c
h.p = c
h.o = b
e.x = j
e.w = j
e.r = l
b.q = c
b.w = c
b.p = c
b.o = h
assert l.y.q.s.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: D = None
        self.q: C = None
        self.s: B = None
        self.txt = txt

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

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

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

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

l = A("l")
c = B("c")
j = C("j")
h = D("h")
e = E("e")
b = D("b")

l.p = c
l.s = c
l.y = b
l.q = j
c.s = l
j.y = e
j.q = l
h.q = c
h.w = c
h.p = c
h.o = b
e.x = j
e.w = j
e.r = l
b.q = c
b.w = c
b.p = c
b.o = h
assert l.y.q.s.y.o.txt == "h"