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

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

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

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

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

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

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

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

l.x = m
l.v = m
l.q = m
m.p = f
f.w = b
f.q = c
i.x = m
i.v = m
i.q = m
d.w = i
d.q = f
g.x = m
g.v = m
g.q = m
c.w = b
c.q = d
b.x = m
b.v = m
b.q = m
assert l.x.p.w.q.p.q.w.txt == "b"