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

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

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

h.s = b
h.y = b
n.p = e
n.q = h
n.w = h
n.y = b
e.r = n
a.u = e
b.w = n
b.r = h
b.s = e
b.u = e
assert h.y.s.r.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.y: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: A = None
        self.s: C = None
        self.u: C = None
        self.txt = txt

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

h.s = b
h.y = b
n.p = e
n.q = h
n.w = h
n.y = b
e.r = n
a.u = e
b.w = n
b.r = h
b.s = e
b.u = e
assert h.y.s.r.w.y.txt == "b"