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

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

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

f.y = c
b.o = c
n.o = e
i.o = c
e.y = c
c.y = e
assert n.o.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.o: A = None
        self.txt = txt

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

f.y = c
b.o = c
n.o = e
i.o = c
e.y = c
c.y = e
assert n.o.y.y.txt == "e"