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

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

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

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

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

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

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

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

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

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

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

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

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