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

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

g = A("g")
d = B("d")
n = A("n")
l = B("l")
j = A("j")
a = B("a")
e = A("e")

g.u = l
d.x = a
n.u = l
l.x = a
j.u = a
a.x = l
e.u = d
assert l.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

g = A("g")
d = B("d")
n = A("n")
l = B("l")
j = A("j")
a = B("a")
e = A("e")

g.u = l
d.x = a
n.u = l
l.x = a
j.u = a
a.x = l
e.u = d
assert l.x.x.x.txt == "a"