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

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

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

f = A("f")
m = B("m")
i = C("i")
h = B("h")
j = B("j")
k = C("k")
g = B("g")
l = A("l")
d = C("d")
a = A("a")

f.q = h
f.u = g
f.t = d
m.x = h
m.t = j
i.x = l
h.x = j
h.t = m
j.x = m
j.t = m
k.x = a
g.x = j
g.t = h
l.q = j
l.u = m
l.t = i
d.x = f
a.q = g
a.u = g
a.t = d
assert d.x.q.x.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.t: C = None
        self.txt = txt

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

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

f = A("f")
m = B("m")
i = C("i")
h = B("h")
j = B("j")
k = C("k")
g = B("g")
l = A("l")
d = C("d")
a = A("a")

f.q = h
f.u = g
f.t = d
m.x = h
m.t = j
i.x = l
h.x = j
h.t = m
j.x = m
j.t = m
k.x = a
g.x = j
g.t = h
l.q = j
l.u = m
l.t = i
d.x = f
a.q = g
a.u = g
a.t = d
assert d.x.q.x.t.t.txt == "j"