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

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

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

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

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

d = A("d")
f = B("f")
n = C("n")
j = D("j")
g = E("g")

d.s = g
d.w = g
d.t = j
d.q = j
f.u = j
f.w = n
f.p = n
n.w = f
j.s = g
g.w = f
g.r = n
g.t = j
assert f.u.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: D = None
        self.w: E = None
        self.q: D = None
        self.txt = txt

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

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

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

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

d = A("d")
f = B("f")
n = C("n")
j = D("j")
g = E("g")

d.s = g
d.w = g
d.t = j
d.q = j
f.u = j
f.w = n
f.p = n
n.w = f
j.s = g
g.w = f
g.r = n
g.t = j
assert f.u.s.w.txt == "f"