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

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

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

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

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

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

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

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

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

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

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