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

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

e = A("e")
k = B("k")
a = A("a")
b = A("b")
j = B("j")

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

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

e = A("e")
k = B("k")
a = A("a")
b = A("b")
j = B("j")

e.p = j
k.s = a
a.p = k
b.p = j
j.s = b
assert b.p.s.p.s.txt == "b"