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

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

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

l = A("l")
c = B("c")
e = C("e")
i = C("i")
m = B("m")
g = A("g")
f = B("f")

l.v = g
l.q = g
l.p = c
c.w = f
c.y = i
e.w = g
i.w = g
m.w = c
m.y = i
g.v = l
g.q = l
g.p = c
f.w = m
f.y = e
assert e.w.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: A = None
        self.p: B = None
        self.txt = txt

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

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

l = A("l")
c = B("c")
e = C("e")
i = C("i")
m = B("m")
g = A("g")
f = B("f")

l.v = g
l.q = g
l.p = c
c.w = f
c.y = i
e.w = g
i.w = g
m.w = c
m.y = i
g.v = l
g.q = l
g.p = c
f.w = m
f.y = e
assert e.w.q.p.txt == "c"