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

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

n = A("n")
j = B("j")
c = A("c")
i = B("i")
h = B("h")
e = A("e")
m = A("m")

n.x = j
j.u = m
j.t = n
c.x = i
i.u = m
i.t = n
h.u = c
h.t = n
e.x = h
m.x = h
assert c.x.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

n = A("n")
j = B("j")
c = A("c")
i = B("i")
h = B("h")
e = A("e")
m = A("m")

n.x = j
j.u = m
j.t = n
c.x = i
i.u = m
i.t = n
h.u = c
h.t = n
e.x = h
m.x = h
assert c.x.t.x.txt == "j"