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

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

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

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

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

d = A("d")
f = B("f")
b = C("b")
l = D("l")
n = E("n")
i = A("i")

d.w = b
d.v = l
d.r = l
f.w = i
f.x = b
b.p = n
b.r = n
b.y = l
l.q = f
l.z = f
l.s = d
l.r = b
n.w = d
i.w = b
i.v = l
i.r = l
assert b.y.r.y.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.v: D = None
        self.r: D = None
        self.txt = txt

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

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

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

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

d = A("d")
f = B("f")
b = C("b")
l = D("l")
n = E("n")
i = A("i")

d.w = b
d.v = l
d.r = l
f.w = i
f.x = b
b.p = n
b.r = n
b.y = l
l.q = f
l.z = f
l.s = d
l.r = b
n.w = d
i.w = b
i.v = l
i.r = l
assert b.y.r.y.r.p.w.txt == "d"