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

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

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

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

l = A("l")
i = B("i")
a = C("a")
g = D("g")
n = B("n")
f = C("f")
h = B("h")

l.v = h
l.y = g
i.r = g
i.z = g
i.y = a
i.w = f
a.z = g
a.q = g
g.u = l
n.r = g
n.z = g
n.y = f
n.w = f
f.z = g
f.q = g
h.r = g
h.z = g
h.y = a
h.w = a
assert n.w.q.u.v.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.y: D = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
a = C("a")
g = D("g")
n = B("n")
f = C("f")
h = B("h")

l.v = h
l.y = g
i.r = g
i.z = g
i.y = a
i.w = f
a.z = g
a.q = g
g.u = l
n.r = g
n.z = g
n.y = f
n.w = f
f.z = g
f.q = g
h.r = g
h.z = g
h.y = a
h.w = a
assert n.w.q.u.v.w.q.txt == "g"