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

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

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

l = A("l")
g = B("g")
d = C("d")
j = A("j")
e = A("e")
i = C("i")
a = B("a")
b = C("b")

l.w = a
l.r = a
l.v = g
g.y = i
g.x = a
g.v = j
d.q = a
j.w = a
j.v = a
j.r = g
e.w = g
e.r = a
e.v = a
i.q = a
a.y = i
a.x = g
a.v = e
b.q = g
assert d.q.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

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

l = A("l")
g = B("g")
d = C("d")
j = A("j")
e = A("e")
i = C("i")
a = B("a")
b = C("b")

l.w = a
l.r = a
l.v = g
g.y = i
g.x = a
g.v = j
d.q = a
j.w = a
j.v = a
j.r = g
e.w = g
e.r = a
e.v = a
i.q = a
a.y = i
a.x = g
a.v = e
b.q = g
assert d.q.v.w.txt == "g"