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

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

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

b = A("b")
c = B("c")
l = C("l")
h = C("h")
i = B("i")
m = A("m")
f = B("f")
k = A("k")

b.q = m
b.x = k
b.u = k
c.q = l
l.v = c
l.x = m
l.y = h
h.v = f
h.x = k
h.y = l
i.q = h
m.q = k
m.u = k
m.x = b
f.q = h
k.q = b
k.x = m
k.u = m
assert h.v.q.y.v.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: A = None
        self.u: A = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
l = C("l")
h = C("h")
i = B("i")
m = A("m")
f = B("f")
k = A("k")

b.q = m
b.x = k
b.u = k
c.q = l
l.v = c
l.x = m
l.y = h
h.v = f
h.x = k
h.y = l
i.q = h
m.q = k
m.u = k
m.x = b
f.q = h
k.q = b
k.x = m
k.u = m
assert h.v.q.y.v.q.x.txt == "m"