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

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: C = None
        self.z: 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.s: A = None
        self.p: C = None
        self.v: A = None
        self.y: A = None
        self.txt = txt

h = A("h")
m = B("m")
b = C("b")
d = D("d")
a = A("a")
n = B("n")

h.t = a
h.w = b
m.s = d
m.v = b
m.z = b
b.x = d
d.s = h
d.v = h
d.y = h
d.p = b
a.t = h
a.w = b
n.s = d
n.v = b
n.z = b
assert a.t.w.x.p.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: C = None
        self.z: 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.s: A = None
        self.p: C = None
        self.v: A = None
        self.y: A = None
        self.txt = txt

h = A("h")
m = B("m")
b = C("b")
d = D("d")
a = A("a")
n = B("n")

h.t = a
h.w = b
m.s = d
m.v = b
m.z = b
b.x = d
d.s = h
d.v = h
d.y = h
d.p = b
a.t = h
a.w = b
n.s = d
n.v = b
n.z = b
assert a.t.w.x.p.x.y.txt == "h"