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

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

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

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

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

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

h.u = j
h.x = k
k.o = h
j.u = h
j.x = b
b.o = h
f.o = j
assert h.u.x.o.txt == "h"