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

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

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

i.p = a
a.r = f
j.p = f
k.p = a
e.p = f
f.r = a
assert a.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

i.p = a
a.r = f
j.p = f
k.p = a
e.p = f
f.r = a
assert a.r.r.r.r.r.r.txt == "a"