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

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

b = A("b")
c = B("c")
n = A("n")
j = B("j")

b.t = n
b.y = n
c.s = n
n.t = b
n.y = b
j.s = b
assert c.s.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

b = A("b")
c = B("c")
n = A("n")
j = B("j")

b.t = n
b.y = n
c.s = n
n.t = b
n.y = b
j.s = b
assert c.s.y.t.y.txt == "b"