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

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

a = A("a")
k = B("k")
l = B("l")
n = B("n")
j = A("j")
c = B("c")
i = B("i")
h = A("h")
d = B("d")

a.x = j
k.y = i
k.u = h
l.y = d
l.u = h
n.y = k
n.u = a
j.x = a
c.y = l
c.u = h
i.y = l
i.u = h
h.x = j
d.y = c
d.u = a
assert c.y.u.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

a = A("a")
k = B("k")
l = B("l")
n = B("n")
j = A("j")
c = B("c")
i = B("i")
h = A("h")
d = B("d")

a.x = j
k.y = i
k.u = h
l.y = d
l.u = h
n.y = k
n.u = a
j.x = a
c.y = l
c.u = h
i.y = l
i.u = h
h.x = j
d.y = c
d.u = a
assert c.y.u.x.txt == "j"