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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.z: C = None
        self.p: A = None
        self.txt = txt

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

b.r = l
b.s = l
b.z = i
i.y = n
i.s = m
i.x = f
a.r = i
l.o = i
l.t = m
l.z = a
l.p = b
n.r = g
n.s = g
n.z = i
k.r = l
k.s = l
k.z = m
m.y = k
m.s = i
m.x = a
f.r = m
g.o = m
g.t = m
g.z = f
g.p = n
assert g.o.y.z.s.y.z.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.z: B = None
        self.s: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: B = None
        self.z: C = None
        self.p: A = None
        self.txt = txt

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

b.r = l
b.s = l
b.z = i
i.y = n
i.s = m
i.x = f
a.r = i
l.o = i
l.t = m
l.z = a
l.p = b
n.r = g
n.s = g
n.z = i
k.r = l
k.s = l
k.z = m
m.y = k
m.s = i
m.x = a
f.r = m
g.o = m
g.t = m
g.z = f
g.p = n
assert g.o.y.z.s.y.z.x.r.txt == "m"