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

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

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

b = A("b")
f = B("f")
c = C("c")
k = C("k")
j = A("j")
h = C("h")
a = A("a")
d = A("d")
m = B("m")
n = C("n")

b.u = j
f.x = d
f.y = b
f.r = b
c.z = h
c.u = n
c.q = k
k.z = c
k.u = n
k.q = h
j.u = d
h.z = c
h.u = c
h.q = k
a.u = j
d.u = b
m.x = d
m.y = a
m.r = a
n.z = c
n.u = k
n.q = k
assert a.u.u.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
c = C("c")
k = C("k")
j = A("j")
h = C("h")
a = A("a")
d = A("d")
m = B("m")
n = C("n")

b.u = j
f.x = d
f.y = b
f.r = b
c.z = h
c.u = n
c.q = k
k.z = c
k.u = n
k.q = h
j.u = d
h.z = c
h.u = c
h.q = k
a.u = j
d.u = b
m.x = d
m.y = a
m.r = a
n.z = c
n.u = k
n.q = k
assert a.u.u.u.u.u.u.u.u.txt == "d"