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

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

class C:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: A = None
        self.txt = txt

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

j.w = h
j.q = d
a.v = f
a.s = h
a.o = h
f.o = n
f.y = j
l.v = n
l.s = h
l.o = j
n.o = f
n.y = d
d.w = j
d.q = j
h.w = j
h.q = d
assert j.w.q.w.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: A = None
        self.txt = txt

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

j.w = h
j.q = d
a.v = f
a.s = h
a.o = h
f.o = n
f.y = j
l.v = n
l.s = h
l.o = j
n.o = f
n.y = d
d.w = j
d.q = j
h.w = j
h.q = d
assert j.w.q.w.w.q.w.txt == "j"