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

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

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

d = A("d")
f = B("f")
h = C("h")
g = B("g")
k = C("k")
c = B("c")
j = B("j")

d.q = c
f.r = g
f.u = g
f.s = h
h.w = c
h.r = f
g.r = j
g.s = h
g.u = f
k.w = g
k.r = g
c.r = g
c.u = g
c.s = k
j.r = c
j.s = h
j.u = g
assert c.r.r.r.s.w.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

d = A("d")
f = B("f")
h = C("h")
g = B("g")
k = C("k")
c = B("c")
j = B("j")

d.q = c
f.r = g
f.u = g
f.s = h
h.w = c
h.r = f
g.r = j
g.s = h
g.u = f
k.w = g
k.r = g
c.r = g
c.u = g
c.s = k
j.r = c
j.s = h
j.u = g
assert c.r.r.r.s.w.r.u.txt == "g"