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

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

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

b = A("b")
n = B("n")
k = C("k")
f = C("f")
i = B("i")
a = B("a")
h = B("h")
m = B("m")
e = A("e")

b.v = e
b.s = i
n.q = f
k.o = f
f.o = k
i.q = k
a.q = f
h.q = f
m.q = k
e.v = b
e.s = h
assert i.q.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.s: B = None
        self.txt = txt

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

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

b = A("b")
n = B("n")
k = C("k")
f = C("f")
i = B("i")
a = B("a")
h = B("h")
m = B("m")
e = A("e")

b.v = e
b.s = i
n.q = f
k.o = f
f.o = k
i.q = k
a.q = f
h.q = f
m.q = k
e.v = b
e.s = h
assert i.q.o.o.o.o.txt == "k"