class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

d = A("d")
m = B("m")
g = C("g")
c = D("c")
j = C("j")
h = C("h")
l = D("l")
i = C("i")

d.v = l
m.v = i
g.w = h
g.q = i
c.x = l
c.y = d
j.w = h
j.q = g
h.w = i
h.q = j
l.x = c
l.y = d
i.w = g
i.q = j
assert c.y.v.x.y.v.y.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

d = A("d")
m = B("m")
g = C("g")
c = D("c")
j = C("j")
h = C("h")
l = D("l")
i = C("i")

d.v = l
m.v = i
g.w = h
g.q = i
c.x = l
c.y = d
j.w = h
j.q = g
h.w = i
h.q = j
l.x = c
l.y = d
i.w = g
i.q = j
assert c.y.v.x.y.v.y.v.x.txt == "c"