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.s: A = None
        self.txt = txt

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

a.u = g
a.t = j
g.x = n
g.s = a
i.x = h
i.s = j
c.u = n
c.t = a
h.x = i
h.s = a
j.u = d
j.t = a
n.x = i
n.s = a
d.x = h
d.s = j
assert h.x.x.x.s.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.s: A = None
        self.txt = txt

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

a.u = g
a.t = j
g.x = n
g.s = a
i.x = h
i.s = j
c.u = n
c.t = a
h.x = i
h.s = a
j.u = d
j.t = a
n.x = i
n.s = a
d.x = h
d.s = j
assert h.x.x.x.s.txt == "j"