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

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

g = A("g")
j = B("j")
e = B("e")
b = A("b")

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

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

g = A("g")
j = B("j")
e = B("e")
b = A("b")

g.y = e
g.s = e
j.p = e
e.p = j
b.y = j
b.s = j
assert j.p.p.p.txt == "e"