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

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

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

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

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

m.o = g
m.r = b
m.y = a
g.r = m
g.w = c
g.z = i
b.s = i
b.v = g
a.s = m
a.v = b
a.z = i
n.r = c
n.w = m
n.z = a
c.o = n
c.r = b
c.y = i
i.s = m
i.v = b
i.z = a
assert b.v.r.r.v.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

m.o = g
m.r = b
m.y = a
g.r = m
g.w = c
g.z = i
b.s = i
b.v = g
a.s = m
a.v = b
a.z = i
n.r = c
n.w = m
n.z = a
c.o = n
c.r = b
c.y = i
i.s = m
i.v = b
i.z = a
assert b.v.r.r.v.r.y.txt == "a"