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

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

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

a = A("a")
l = B("l")
i = C("i")
e = B("e")
k = B("k")
m = C("m")
n = A("n")
b = C("b")
c = A("c")
g = C("g")

a.w = b
l.v = i
l.x = b
l.p = n
i.y = b
e.v = b
e.x = b
e.p = a
k.v = i
k.x = i
k.p = a
m.y = i
n.w = i
b.y = i
c.w = b
g.y = i
assert k.p.w.y.y.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

a = A("a")
l = B("l")
i = C("i")
e = B("e")
k = B("k")
m = C("m")
n = A("n")
b = C("b")
c = A("c")
g = C("g")

a.w = b
l.v = i
l.x = b
l.p = n
i.y = b
e.v = b
e.x = b
e.p = a
k.v = i
k.x = i
k.p = a
m.y = i
n.w = i
b.y = i
c.w = b
g.y = i
assert k.p.w.y.y.y.y.y.y.y.y.txt == "b"