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

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

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

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

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

d = A("d")
f = B("f")
n = C("n")
e = D("e")
c = E("c")
m = D("m")

d.o = c
d.x = c
d.y = f
d.r = n
f.x = c
n.o = f
n.r = f
n.t = f
n.w = d
n.y = c
e.t = d
c.s = f
c.x = f
c.z = f
c.w = m
c.r = n
m.t = d
assert d.x.s.x.r.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.x: E = None
        self.y: B = None
        self.r: C = None
        self.txt = txt

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

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

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

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

d = A("d")
f = B("f")
n = C("n")
e = D("e")
c = E("c")
m = D("m")

d.o = c
d.x = c
d.y = f
d.r = n
f.x = c
n.o = f
n.r = f
n.t = f
n.w = d
n.y = c
e.t = d
c.s = f
c.x = f
c.z = f
c.w = m
c.r = n
m.t = d
assert d.x.s.x.r.w.r.txt == "n"