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

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

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

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

d = A("d")
g = B("g")
b = C("b")
m = D("m")
h = D("h")
l = A("l")

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

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

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

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

d = A("d")
g = B("g")
b = C("b")
m = D("m")
h = D("h")
l = A("l")

d.y = b
d.x = g
d.w = l
g.z = b
b.w = g
b.z = g
b.r = m
m.s = b
m.t = b
m.v = l
h.s = b
h.t = b
h.v = d
l.y = b
l.x = g
l.w = d
assert h.t.w.z.r.txt == "m"