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

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

j = A("j")
c = B("c")
f = B("f")
n = A("n")
d = B("d")
l = B("l")
i = B("i")
h = B("h")
b = A("b")

j.y = f
c.o = n
f.o = b
n.y = d
d.o = j
l.o = n
i.o = j
h.o = n
b.y = f
assert n.y.o.y.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

j = A("j")
c = B("c")
f = B("f")
n = A("n")
d = B("d")
l = B("l")
i = B("i")
h = B("h")
b = A("b")

j.y = f
c.o = n
f.o = b
n.y = d
d.o = j
l.o = n
i.o = j
h.o = n
b.y = f
assert n.y.o.y.o.y.o.txt == "b"