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

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

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

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

n = A("n")
e = B("e")
a = C("a")
i = D("i")
b = C("b")
l = A("l")

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

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

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

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

n = A("n")
e = B("e")
a = C("a")
i = D("i")
b = C("b")
l = A("l")

n.o = e
e.y = b
e.r = l
a.q = b
a.s = e
i.s = e
i.x = e
i.q = a
i.y = n
b.q = a
b.s = e
l.o = e
assert n.o.y.s.r.o.r.txt == "l"