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

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

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

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

m = A("m")
f = B("f")
j = C("j")
g = D("g")
d = C("d")
l = A("l")
i = C("i")

m.v = l
m.s = l
m.y = l
m.z = i
f.z = l
f.q = m
f.u = d
f.v = j
j.z = l
j.r = f
g.u = j
g.r = f
d.z = l
d.r = f
l.v = m
l.s = m
l.y = m
l.z = d
i.z = l
i.r = f
assert f.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.s: A = None
        self.z: C = None
        self.y: A = None
        self.txt = txt

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

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

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

m = A("m")
f = B("f")
j = C("j")
g = D("g")
d = C("d")
l = A("l")
i = C("i")

m.v = l
m.s = l
m.y = l
m.z = i
f.z = l
f.q = m
f.u = d
f.v = j
j.z = l
j.r = f
g.u = j
g.r = f
d.z = l
d.r = f
l.v = m
l.s = m
l.y = m
l.z = d
i.z = l
i.r = f
assert f.z.v.z.txt == "i"