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.txt = txt

c = A("c")
e = B("e")
g = A("g")
l = B("l")
i = B("i")
d = A("d")
n = B("n")
m = B("m")
h = A("h")

c.x = i
e.u = h
g.x = e
l.u = h
i.u = g
d.x = m
n.u = g
m.u = h
h.x = n
assert m.u.x.u.x.u.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.txt = txt

c = A("c")
e = B("e")
g = A("g")
l = B("l")
i = B("i")
d = A("d")
n = B("n")
m = B("m")
h = A("h")

c.x = i
e.u = h
g.x = e
l.u = h
i.u = g
d.x = m
n.u = g
m.u = h
h.x = n
assert m.u.x.u.x.u.x.txt == "n"