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

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

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

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

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

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

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

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

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

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

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

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

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