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

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: A = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.r: C = None
        self.x: A = None
        self.t: C = None
        self.u: A = None
        self.txt = txt

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

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