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

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

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

b = A("b")
f = B("f")
e = C("e")
k = B("k")
i = B("i")
l = B("l")
g = A("g")
n = C("n")

b.o = g
f.q = b
f.v = b
e.o = g
k.q = b
k.v = b
i.q = g
i.v = b
l.q = g
l.v = g
g.o = b
n.o = b
assert i.v.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

b = A("b")
f = B("f")
e = C("e")
k = B("k")
i = B("i")
l = B("l")
g = A("g")
n = C("n")

b.o = g
f.q = b
f.v = b
e.o = g
k.q = b
k.v = b
i.q = g
i.v = b
l.q = g
l.v = g
g.o = b
n.o = b
assert i.v.o.o.o.o.o.txt == "g"