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

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

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

j = A("j")
e = B("e")
h = C("h")
b = B("b")
d = B("d")
k = A("k")
i = B("i")
c = A("c")
f = B("f")

j.q = c
j.v = e
e.s = h
h.z = d
b.s = h
d.s = h
k.q = j
k.v = i
i.s = h
c.q = k
c.v = i
f.s = h
assert b.s.z.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.v: B = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
h = C("h")
b = B("b")
d = B("d")
k = A("k")
i = B("i")
c = A("c")
f = B("f")

j.q = c
j.v = e
e.s = h
h.z = d
b.s = h
d.s = h
k.q = j
k.v = i
i.s = h
c.q = k
c.v = i
f.s = h
assert b.s.z.s.z.s.z.txt == "d"