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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: A = None
        self.p: A = None
        self.txt = txt

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

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

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

h.t = e
h.z = g
h.q = g
i.s = g
i.p = c
i.u = c
g.v = i
g.q = h
g.p = m
e.s = i
c.u = h
c.z = i
m.t = e
m.z = g
m.q = g
assert i.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.z: C = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: A = None
        self.p: A = None
        self.txt = txt

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

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

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

h.t = e
h.z = g
h.q = g
i.s = g
i.p = c
i.u = c
g.v = i
g.q = h
g.p = m
e.s = i
c.u = h
c.z = i
m.t = e
m.z = g
m.q = g
assert i.s.v.s.txt == "g"