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

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

h = A("h")
g = B("g")
d = A("d")
b = B("b")
e = A("e")
a = A("a")
f = B("f")
l = A("l")

h.u = b
h.t = l
g.x = b
g.y = l
d.u = b
d.t = a
b.x = g
b.y = d
e.u = b
e.t = a
a.u = g
a.t = l
f.x = g
f.y = h
l.u = g
l.t = a
assert f.y.t.u.y.t.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: A = None
        self.txt = txt

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

h = A("h")
g = B("g")
d = A("d")
b = B("b")
e = A("e")
a = A("a")
f = B("f")
l = A("l")

h.u = b
h.t = l
g.x = b
g.y = l
d.u = b
d.t = a
b.x = g
b.y = d
e.u = b
e.t = a
a.u = g
a.t = l
f.x = g
f.y = h
l.u = g
l.t = a
assert f.y.t.u.y.t.t.u.txt == "g"