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

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

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

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

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

b = A("b")
a = B("a")
i = C("i")
n = D("n")
d = E("d")

b.w = n
b.q = n
a.w = n
a.p = n
a.z = i
a.y = d
i.p = n
i.t = d
n.w = b
n.v = b
n.z = a
n.q = a
d.s = i
assert d.s.t.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: D = None
        self.txt = txt

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

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

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

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

b = A("b")
a = B("a")
i = C("i")
n = D("n")
d = E("d")

b.w = n
b.q = n
a.w = n
a.p = n
a.z = i
a.y = d
i.p = n
i.t = d
n.w = b
n.v = b
n.z = a
n.q = a
d.s = i
assert d.s.t.s.t.s.txt == "i"