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

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

f = A("f")
n = B("n")
i = B("i")
e = A("e")
d = A("d")
c = B("c")

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

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

f = A("f")
n = B("n")
i = B("i")
e = A("e")
d = A("d")
c = B("c")

f.y = c
n.s = i
n.z = i
i.s = n
i.z = n
e.y = i
d.y = n
c.s = n
c.z = n
assert e.y.s.s.z.s.txt == "i"