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

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

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

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

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

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

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

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

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

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

d.y = a
d.s = a
d.v = g
a.s = b
g.o = a
g.r = a
g.y = h
b.v = a
b.y = i
b.w = i
b.z = d
h.o = a
h.r = a
h.y = m
i.y = a
i.s = a
i.v = g
l.v = a
l.y = i
l.z = d
l.w = d
m.o = a
m.r = a
m.y = g
assert d.v.r.s.txt == "b"