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

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

f = A("f")
i = B("i")
l = B("l")
c = B("c")
h = B("h")
k = A("k")
e = B("e")
a = B("a")
n = A("n")

f.x = k
f.s = l
i.x = n
i.r = k
l.x = k
l.r = f
c.x = n
c.r = f
h.x = f
h.r = f
k.x = f
k.s = c
e.x = k
e.r = f
a.x = f
a.r = k
n.x = f
n.s = e
assert f.s.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.txt = txt

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

f = A("f")
i = B("i")
l = B("l")
c = B("c")
h = B("h")
k = A("k")
e = B("e")
a = B("a")
n = A("n")

f.x = k
f.s = l
i.x = n
i.r = k
l.x = k
l.r = f
c.x = n
c.r = f
h.x = f
h.r = f
k.x = f
k.s = c
e.x = k
e.r = f
a.x = f
a.r = k
n.x = f
n.s = e
assert f.s.r.s.r.txt == "f"