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

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

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

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

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

g = A("g")
c = B("c")
d = C("d")
m = D("m")
e = E("e")

g.z = m
c.w = e
d.x = e
d.r = g
m.v = g
e.s = g
e.t = c
assert m.v.z.v.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

g = A("g")
c = B("c")
d = C("d")
m = D("m")
e = E("e")

g.z = m
c.w = e
d.x = e
d.r = g
m.v = g
e.s = g
e.t = c
assert m.v.z.v.txt == "g"