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

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

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

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

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

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

b.p = n
d.q = a
j.r = b
j.w = d
j.p = a
a.z = j
a.v = n
a.y = d
a.u = d
a.w = b
n.z = d
assert b.p.z.q.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

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

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

b.p = n
d.q = a
j.r = b
j.w = d
j.p = a
a.z = j
a.v = n
a.y = d
a.u = d
a.w = b
n.z = d
assert b.p.z.q.v.z.txt == "d"