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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: A = None
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
g = C("g")
b = D("b")
c = C("c")
d = B("d")
h = D("h")

a.s = e
a.w = g
e.w = a
e.r = a
e.t = a
e.s = d
g.z = c
g.r = a
b.y = a
c.z = g
c.r = a
d.w = a
d.r = a
d.t = a
d.s = e
h.y = a
assert d.s.s.s.r.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: A = None
        self.s: B = None
        self.t: A = None
        self.txt = txt

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

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

a = A("a")
e = B("e")
g = C("g")
b = D("b")
c = C("c")
d = B("d")
h = D("h")

a.s = e
a.w = g
e.w = a
e.r = a
e.t = a
e.s = d
g.z = c
g.r = a
b.y = a
c.z = g
c.r = a
d.w = a
d.r = a
d.t = a
d.s = e
h.y = a
assert d.s.s.s.r.w.z.txt == "c"