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

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

j = A("j")
d = B("d")
k = A("k")
n = A("n")

j.t = k
j.s = d
d.o = n
k.t = j
k.s = d
n.t = j
n.s = d
assert k.s.o.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: B = None
        self.txt = txt

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

j = A("j")
d = B("d")
k = A("k")
n = A("n")

j.t = k
j.s = d
d.o = n
k.t = j
k.s = d
n.t = j
n.s = d
assert k.s.o.s.o.txt == "n"