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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: A = None
        self.p: C = None
        self.txt = txt

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

b.o = e
g.v = m
g.p = f
i.s = b
i.x = b
i.p = m
e.o = k
d.v = i
d.p = g
k.o = b
l.s = k
l.x = k
l.p = m
m.s = k
m.x = b
m.p = i
f.v = m
f.p = d
assert e.o.o.o.o.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.v: C = None
        self.p: B = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: A = None
        self.p: C = None
        self.txt = txt

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

b.o = e
g.v = m
g.p = f
i.s = b
i.x = b
i.p = m
e.o = k
d.v = i
d.p = g
k.o = b
l.s = k
l.x = k
l.p = m
m.s = k
m.x = b
m.p = i
f.v = m
f.p = d
assert e.o.o.o.o.o.o.o.o.o.txt == "e"