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

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

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

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

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

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

b.z = c
c.t = j
e.y = c
e.w = j
e.x = j
j.x = b
m.v = e
assert m.v.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

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

b.z = c
c.t = j
e.y = c
e.w = j
e.x = j
j.x = b
m.v = e
assert m.v.w.x.txt == "b"