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

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

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

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

m = A("m")
b = B("b")
d = C("d")
g = D("g")
k = A("k")
n = A("n")
h = B("h")
a = C("a")
j = D("j")
f = C("f")

m.s = g
m.y = b
m.w = h
b.v = j
b.p = k
d.z = j
g.z = n
g.r = n
g.w = j
k.s = j
k.y = h
k.w = b
n.s = g
n.y = b
n.w = b
h.v = g
h.p = m
a.z = g
j.z = k
j.r = k
j.w = g
f.z = g
assert f.z.r.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

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

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

m = A("m")
b = B("b")
d = C("d")
g = D("g")
k = A("k")
n = A("n")
h = B("h")
a = C("a")
j = D("j")
f = C("f")

m.s = g
m.y = b
m.w = h
b.v = j
b.p = k
d.z = j
g.z = n
g.r = n
g.w = j
k.s = j
k.y = h
k.w = b
n.s = g
n.y = b
n.w = b
h.v = g
h.p = m
a.z = g
j.z = k
j.r = k
j.w = g
f.z = g
assert f.z.r.y.p.txt == "k"