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

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

a = A("a")
g = B("g")
k = A("k")
l = A("l")
f = B("f")
c = A("c")
i = A("i")
j = A("j")

a.x = f
a.t = c
g.u = f
g.y = k
k.x = f
k.t = j
l.x = f
l.t = c
f.u = g
f.y = k
c.x = g
c.t = j
i.x = f
i.t = a
j.x = f
j.t = i
assert g.u.u.y.t.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: A = None
        self.txt = txt

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

a = A("a")
g = B("g")
k = A("k")
l = A("l")
f = B("f")
c = A("c")
i = A("i")
j = A("j")

a.x = f
a.t = c
g.u = f
g.y = k
k.x = f
k.t = j
l.x = f
l.t = c
f.u = g
f.y = k
c.x = g
c.t = j
i.x = f
i.t = a
j.x = f
j.t = i
assert g.u.u.y.t.t.x.txt == "f"