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

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

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

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

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

a.s = d
a.z = d
a.t = h
a.u = g
g.s = a
d.v = h
d.p = h
d.t = g
h.w = d
c.s = d
c.z = d
c.t = h
c.u = g
assert c.t.w.p.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.t: D = None
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

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

a.s = d
a.z = d
a.t = h
a.u = g
g.s = a
d.v = h
d.p = h
d.t = g
h.w = d
c.s = d
c.z = d
c.t = h
c.u = g
assert c.t.w.p.w.v.txt == "h"