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

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

k = A("k")
f = B("f")
h = A("h")
c = B("c")
l = B("l")

k.x = h
k.s = h
f.o = k
f.v = h
h.x = k
h.s = k
c.o = h
c.v = k
l.o = h
l.v = k
assert k.x.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: A = None
        self.txt = txt

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

k = A("k")
f = B("f")
h = A("h")
c = B("c")
l = B("l")

k.x = h
k.s = h
f.o = k
f.v = h
h.x = k
h.s = k
c.o = h
c.v = k
l.o = h
l.v = k
assert k.x.s.x.s.txt == "k"