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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: B = None
        self.r: B = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: B = None
        self.r: B = None
        self.p: D = None
        self.txt = txt

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

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

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

d.s = g
d.o = g
g.t = f
h.z = f
h.p = f
h.y = g
h.r = g
f.q = d
i.s = h
i.x = f
assert f.q.o.t.q.txt == "d"