class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: C = None
        self.t: D = None
        self.x: E = None
        self.txt = txt

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

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

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

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

i = A("i")
d = B("d")
b = C("b")
h = D("h")
e = E("e")

i.s = h
i.t = h
i.v = b
i.x = e
d.s = e
b.v = i
b.y = e
h.r = b
e.q = d
e.x = d
e.z = i
assert i.v.y.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: C = None
        self.t: D = None
        self.x: E = None
        self.txt = txt

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

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

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

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

i = A("i")
d = B("d")
b = C("b")
h = D("h")
e = E("e")

i.s = h
i.t = h
i.v = b
i.x = e
d.s = e
b.v = i
b.y = e
h.r = b
e.q = d
e.x = d
e.z = i
assert i.v.y.z.x.txt == "e"