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

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

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

d = A("d")
l = B("l")
f = C("f")
k = C("k")
n = A("n")
h = A("h")
j = B("j")
m = A("m")

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

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

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

d = A("d")
l = B("l")
f = C("f")
k = C("k")
n = A("n")
h = A("h")
j = B("j")
m = A("m")

d.q = j
d.r = k
l.z = j
l.x = d
f.w = k
f.t = k
f.u = h
k.w = f
k.t = f
k.u = m
n.q = j
n.r = k
h.q = j
h.r = f
j.z = l
j.x = d
m.q = l
m.r = k
assert m.q.x.r.t.u.q.x.r.txt == "k"