class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.t: C = None
        self.w: C = None
        self.txt = txt

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

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

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

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

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

d.o = c
d.t = b
d.w = b
n.r = e
n.q = a
b.x = n
b.w = e
e.w = d
e.o = a
e.q = a
c.p = n
c.q = e
a.p = n
a.q = e
assert c.p.q.p.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.t: C = None
        self.w: C = None
        self.txt = txt

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

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

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

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

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

d.o = c
d.t = b
d.w = b
n.r = e
n.q = a
b.x = n
b.w = e
e.w = d
e.o = a
e.q = a
c.p = n
c.q = e
a.p = n
a.q = e
assert c.p.q.p.r.w.txt == "d"