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

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

a = A("a")
f = B("f")
c = C("c")
m = C("m")
h = B("h")
l = C("l")
d = A("d")
n = A("n")
e = B("e")
k = B("k")

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

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

class C:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

a = A("a")
f = B("f")
c = C("c")
m = C("m")
h = B("h")
l = C("l")
d = A("d")
n = A("n")
e = B("e")
k = B("k")

a.x = n
a.u = n
a.y = d
f.w = l
c.w = l
m.w = c
h.w = l
l.w = m
d.x = n
d.u = n
d.y = n
n.x = a
n.u = a
n.y = d
e.w = m
k.w = c
assert f.w.w.w.w.w.w.w.txt == "l"