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

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

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

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

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

a = A("a")
m = B("m")
n = C("n")
b = D("b")
h = E("h")

a.w = m
a.p = n
a.o = n
m.y = b
n.r = h
b.s = a
h.x = a
h.q = a
h.t = b
assert m.y.s.o.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.p: C = None
        self.o: C = None
        self.txt = txt

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

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

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

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

a = A("a")
m = B("m")
n = C("n")
b = D("b")
h = E("h")

a.w = m
a.p = n
a.o = n
m.y = b
n.r = h
b.s = a
h.x = a
h.q = a
h.t = b
assert m.y.s.o.r.t.txt == "b"