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

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

i = A("i")
k = B("k")
d = A("d")
a = B("a")
n = B("n")
c = B("c")
b = B("b")
h = B("h")
l = A("l")

i.y = l
k.s = h
k.z = i
d.y = i
a.s = k
a.z = i
n.s = b
n.z = i
c.s = n
c.z = i
b.s = c
b.z = l
h.s = a
h.z = l
l.y = i
assert i.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

i = A("i")
k = B("k")
d = A("d")
a = B("a")
n = B("n")
c = B("c")
b = B("b")
h = B("h")
l = A("l")

i.y = l
k.s = h
k.z = i
d.y = i
a.s = k
a.z = i
n.s = b
n.z = i
c.s = n
c.z = i
b.s = c
b.z = l
h.s = a
h.z = l
l.y = i
assert i.y.y.y.y.y.y.txt == "i"