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

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

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

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

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

j = A("j")
f = B("f")
a = C("a")
m = D("m")
c = E("c")

j.v = f
f.w = a
f.v = j
f.r = j
f.s = m
a.t = j
a.y = f
m.z = c
m.s = c
m.v = c
m.y = j
c.q = a
assert c.q.y.w.t.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

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

j = A("j")
f = B("f")
a = C("a")
m = D("m")
c = E("c")

j.v = f
f.w = a
f.v = j
f.r = j
f.s = m
a.t = j
a.y = f
m.z = c
m.s = c
m.v = c
m.y = j
c.q = a
assert c.q.y.w.t.v.txt == "f"