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

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

a = A("a")
d = B("d")
n = B("n")
b = B("b")
l = B("l")
m = A("m")
k = B("k")
g = A("g")
c = B("c")

a.y = g
a.u = m
d.u = b
d.x = c
n.u = b
n.x = c
b.u = l
b.x = c
l.u = c
l.x = c
m.y = a
m.u = g
k.u = c
k.x = b
g.y = m
g.u = a
c.u = l
c.x = l
assert g.y.u.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.txt = txt

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

a = A("a")
d = B("d")
n = B("n")
b = B("b")
l = B("l")
m = A("m")
k = B("k")
g = A("g")
c = B("c")

a.y = g
a.u = m
d.u = b
d.x = c
n.u = b
n.x = c
b.u = l
b.x = c
l.u = c
l.x = c
m.y = a
m.u = g
k.u = c
k.x = b
g.y = m
g.u = a
c.u = l
c.x = l
assert g.y.u.y.y.u.txt == "m"