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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

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