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

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

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

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

l.p = b
g.z = i
g.o = i
k.p = l
k.x = i
k.v = g
b.p = d
b.x = d
b.v = g
m.p = d
m.x = i
m.v = g
e.p = l
e.x = d
e.v = g
d.p = b
i.p = m
assert i.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

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

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