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

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

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

b = A("b")
d = B("d")
g = C("g")
c = C("c")
m = B("m")
l = A("l")
f = B("f")
h = B("h")

b.o = l
d.w = b
d.v = c
d.u = c
g.q = c
g.p = b
g.o = f
c.q = g
c.p = l
c.o = f
m.w = l
m.v = g
m.u = g
l.o = b
f.w = b
f.v = g
f.u = g
h.w = l
h.v = c
h.u = g
assert c.p.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.w: A = None
        self.v: C = None
        self.u: C = None
        self.txt = txt

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

b = A("b")
d = B("d")
g = C("g")
c = C("c")
m = B("m")
l = A("l")
f = B("f")
h = B("h")

b.o = l
d.w = b
d.v = c
d.u = c
g.q = c
g.p = b
g.o = f
c.q = g
c.p = l
c.o = f
m.w = l
m.v = g
m.u = g
l.o = b
f.w = b
f.v = g
f.u = g
h.w = l
h.v = c
h.u = g
assert c.p.o.o.o.o.o.o.o.txt == "b"