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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: E = None
        self.v: A = None
        self.r: A = None
        self.txt = txt

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

d = A("d")
m = B("m")
i = C("i")
h = D("h")
a = E("a")

d.s = m
d.o = a
d.x = i
m.w = h
m.s = d
m.p = a
i.y = d
i.s = a
h.y = d
h.v = d
h.r = d
h.o = a
a.r = i
a.o = m
assert d.s.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.o: E = None
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: E = None
        self.v: A = None
        self.r: A = None
        self.txt = txt

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

d = A("d")
m = B("m")
i = C("i")
h = D("h")
a = E("a")

d.s = m
d.o = a
d.x = i
m.w = h
m.s = d
m.p = a
i.y = d
i.s = a
h.y = d
h.v = d
h.r = d
h.o = a
a.r = i
a.o = m
assert d.s.s.o.txt == "a"