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

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

k = A("k")
g = B("g")
c = B("c")
h = B("h")
e = A("e")
j = B("j")

k.x = e
g.s = k
c.s = e
h.s = e
e.x = k
j.s = e
assert k.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

k = A("k")
g = B("g")
c = B("c")
h = B("h")
e = A("e")
j = B("j")

k.x = e
g.s = k
c.s = e
h.s = e
e.x = k
j.s = e
assert k.x.x.x.x.x.txt == "e"