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

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.x: B = None
        self.w: C = None
        self.v: A = None
        self.txt = txt

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

j = A("j")
n = B("n")
b = C("b")
e = D("e")
c = E("c")
d = A("d")
l = D("l")
a = E("a")

j.q = l
n.p = e
n.q = e
b.p = j
b.w = n
e.r = n
e.u = n
e.x = n
e.w = b
e.v = j
c.y = j
c.s = e
d.q = e
l.r = n
l.u = n
l.x = n
l.w = b
l.v = d
a.y = d
a.s = e
assert l.w.w.q.w.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.x: B = None
        self.w: C = None
        self.v: A = None
        self.txt = txt

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

j = A("j")
n = B("n")
b = C("b")
e = D("e")
c = E("c")
d = A("d")
l = D("l")
a = E("a")

j.q = l
n.p = e
n.q = e
b.p = j
b.w = n
e.r = n
e.u = n
e.x = n
e.w = b
e.v = j
c.y = j
c.s = e
d.q = e
l.r = n
l.u = n
l.x = n
l.w = b
l.v = d
a.y = d
a.s = e
assert l.w.w.q.w.w.q.w.txt == "b"