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

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

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

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

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

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

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

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

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

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

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

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

l.s = f
l.q = f
l.w = m
l.y = c
b.r = e
m.z = c
m.r = b
m.y = b
m.s = b
f.p = l
e.w = b
e.p = l
c.z = m
c.r = b
c.y = b
c.s = b
j.p = l
assert e.w.r.w.r.w.r.w.txt == "b"