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

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

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

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

h = A("h")
f = B("f")
b = C("b")
n = D("n")
m = B("m")
d = B("d")
g = D("g")
e = C("e")
j = D("j")

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

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

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

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

h = A("h")
f = B("f")
b = C("b")
n = D("n")
m = B("m")
d = B("d")
g = D("g")
e = C("e")
j = D("j")

h.z = e
h.s = j
f.y = h
f.p = h
f.r = e
f.q = b
b.x = n
n.w = e
m.y = h
m.p = h
m.r = b
m.q = e
d.y = h
d.p = h
d.r = e
d.q = b
g.w = e
e.x = j
j.w = e
assert g.w.x.w.txt == "e"