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

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

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

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

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

h = A("h")
i = B("i")
m = C("m")
d = D("d")
g = E("g")

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

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

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

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

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

h = A("h")
i = B("i")
m = C("m")
d = D("d")
g = E("g")

h.t = d
h.z = i
i.s = d
i.z = d
i.p = h
i.v = h
m.w = d
m.z = d
m.x = i
m.v = g
d.v = i
g.r = m
g.s = m
g.v = h
assert m.x.p.t.v.txt == "i"