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

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

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

b = A("b")
h = B("h")
d = C("d")
a = B("a")
f = C("f")
k = C("k")

b.q = a
b.w = k
b.t = h
h.w = d
h.v = a
d.p = h
d.w = h
a.w = d
a.v = h
f.p = h
f.w = a
k.p = a
k.w = h
assert d.p.v.w.w.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: C = None
        self.t: B = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
d = C("d")
a = B("a")
f = C("f")
k = C("k")

b.q = a
b.w = k
b.t = h
h.w = d
h.v = a
d.p = h
d.w = h
a.w = d
a.v = h
f.p = h
f.w = a
k.p = a
k.w = h
assert d.p.v.w.w.v.w.txt == "d"