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

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

i = A("i")
f = B("f")
e = B("e")
j = B("j")
n = A("n")
k = A("k")

i.x = f
f.y = k
e.y = k
j.y = k
n.x = e
k.x = f
assert n.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

i = A("i")
f = B("f")
e = B("e")
j = B("j")
n = A("n")
k = A("k")

i.x = f
f.y = k
e.y = k
j.y = k
n.x = e
k.x = f
assert n.x.y.x.txt == "f"