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

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

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

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

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

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

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

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

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

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

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

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

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