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

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

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

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

b = A("b")
k = B("k")
m = C("m")
d = D("d")
g = B("g")
n = C("n")
a = A("a")
i = D("i")

b.v = m
b.x = m
k.v = b
k.x = m
k.w = d
m.p = b
m.y = b
m.s = k
m.r = n
d.r = k
d.z = m
d.w = n
g.v = b
g.x = m
g.w = d
n.p = b
n.s = g
n.y = a
n.r = m
a.v = m
a.x = n
i.r = k
i.z = m
i.w = n
assert i.z.y.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: C = None
        self.txt = txt

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

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

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

b = A("b")
k = B("k")
m = C("m")
d = D("d")
g = B("g")
n = C("n")
a = A("a")
i = D("i")

b.v = m
b.x = m
k.v = b
k.x = m
k.w = d
m.p = b
m.y = b
m.s = k
m.r = n
d.r = k
d.z = m
d.w = n
g.v = b
g.x = m
g.w = d
n.p = b
n.s = g
n.y = a
n.r = m
a.v = m
a.x = n
i.r = k
i.z = m
i.w = n
assert i.z.y.v.r.txt == "n"