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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: B = None
        self.q: E = None
        self.r: A = None
        self.s: D = None
        self.txt = txt

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

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

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

f.q = g
i.r = f
a.t = g
a.q = g
a.p = i
a.r = f
a.s = h
h.v = a
h.q = a
h.z = i
g.s = f
g.w = i
g.v = a
assert g.v.s.z.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.t: E = None
        self.p: B = None
        self.q: E = None
        self.r: A = None
        self.s: D = None
        self.txt = txt

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

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

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

f.q = g
i.r = f
a.t = g
a.q = g
a.p = i
a.r = f
a.s = h
h.v = a
h.q = a
h.z = i
g.s = f
g.w = i
g.v = a
assert g.v.s.z.r.q.txt == "g"