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

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

k = A("k")
h = B("h")
j = A("j")

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

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

k = A("k")
h = B("h")
j = A("j")

k.s = h
h.u = j
h.o = j
j.s = h
assert j.s.u.s.txt == "h"