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

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

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

c = A("c")
j = B("j")
e = C("e")
h = B("h")
g = C("g")
a = B("a")
l = A("l")
d = B("d")
m = C("m")

c.x = h
j.v = g
j.y = d
e.t = j
e.q = a
e.y = m
h.v = m
h.y = d
g.t = j
g.q = d
g.y = m
a.v = g
a.y = d
l.x = j
d.v = m
d.y = a
m.t = h
m.q = h
m.y = g
assert d.y.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
e = C("e")
h = B("h")
g = C("g")
a = B("a")
l = A("l")
d = B("d")
m = C("m")

c.x = h
j.v = g
j.y = d
e.t = j
e.q = a
e.y = m
h.v = m
h.y = d
g.t = j
g.q = d
g.y = m
a.v = g
a.y = d
l.x = j
d.v = m
d.y = a
m.t = h
m.q = h
m.y = g
assert d.y.v.q.txt == "d"