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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

b.s = h
b.w = n
b.t = n
b.p = n
g.w = n
g.q = e
h.q = b
n.r = e
n.t = b
n.u = h
e.r = h
assert n.t.w.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: D = None
        self.t: D = None
        self.p: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

b.s = h
b.w = n
b.t = n
b.p = n
g.w = n
g.q = e
h.q = b
n.r = e
n.t = b
n.u = h
e.r = h
assert n.t.w.r.r.txt == "h"