class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: E = None
        self.r: C = None
        self.o: E = None
        self.p: B = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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