class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: E = None
        self.z: C = None
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: A = None
        self.u: A = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
m = C("m")
d = D("d")
b = E("b")

f.o = g
f.x = b
f.y = b
f.z = m
g.u = d
g.w = m
m.p = g
m.y = f
m.u = f
d.t = f
d.w = m
d.x = b
d.p = g
b.o = f
b.u = g
assert g.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: E = None
        self.z: C = None
        self.y: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: A = None
        self.u: A = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
m = C("m")
d = D("d")
b = E("b")

f.o = g
f.x = b
f.y = b
f.z = m
g.u = d
g.w = m
m.p = g
m.y = f
m.u = f
d.t = f
d.w = m
d.x = b
d.p = g
b.o = f
b.u = g
assert g.w.p.w.p.txt == "g"