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

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

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

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

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

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

f.o = h
f.s = b
d.y = f
d.u = m
d.x = b
b.s = d
b.y = m
h.w = d
h.p = m
m.x = b
assert f.s.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

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

f.o = h
f.s = b
d.y = f
d.u = m
d.x = b
b.s = d
b.y = m
h.w = d
h.p = m
m.x = b
assert f.s.y.x.txt == "b"