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

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

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

h = A("h")
i = B("i")
j = C("j")
f = C("f")
e = B("e")
b = B("b")
g = C("g")

h.p = b
h.v = i
i.u = j
i.y = j
i.q = g
j.x = g
j.w = f
f.x = j
f.w = j
e.u = f
e.y = f
e.q = g
b.u = j
b.y = f
b.q = g
g.x = j
g.w = f
assert e.q.w.x.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

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

h = A("h")
i = B("i")
j = C("j")
f = C("f")
e = B("e")
b = B("b")
g = C("g")

h.p = b
h.v = i
i.u = j
i.y = j
i.q = g
j.x = g
j.w = f
f.x = j
f.w = j
e.u = f
e.y = f
e.q = g
b.u = j
b.y = f
b.q = g
g.x = j
g.w = f
assert e.q.w.x.w.w.w.txt == "f"