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

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

f = A("f")
n = B("n")
a = B("a")
e = A("e")
k = B("k")
i = B("i")
m = A("m")

f.z = e
f.y = a
n.s = e
a.s = m
e.z = f
e.y = a
k.s = e
i.s = f
m.z = f
m.y = n
assert e.z.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.y: B = None
        self.txt = txt

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

f = A("f")
n = B("n")
a = B("a")
e = A("e")
k = B("k")
i = B("i")
m = A("m")

f.z = e
f.y = a
n.s = e
a.s = m
e.z = f
e.y = a
k.s = e
i.s = f
m.z = f
m.y = n
assert e.z.z.y.txt == "a"