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

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

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

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

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

h = A("h")
n = B("n")
d = C("d")
b = D("b")
j = E("j")

h.s = b
h.x = d
n.x = h
n.y = b
d.z = j
d.r = j
b.w = n
j.w = b
j.u = b
assert b.w.y.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: C = None
        self.txt = txt

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

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

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

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

h = A("h")
n = B("n")
d = C("d")
b = D("b")
j = E("j")

h.s = b
h.x = d
n.x = h
n.y = b
d.z = j
d.r = j
b.w = n
j.w = b
j.u = b
assert b.w.y.w.x.txt == "h"