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

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

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

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

a = A("a")
i = B("i")
j = C("j")
g = D("g")
d = D("d")
n = B("n")
k = B("k")
e = B("e")

a.y = j
i.x = j
i.q = j
i.v = a
j.w = a
g.q = k
d.q = e
n.x = j
n.q = j
n.v = a
k.x = j
k.q = j
k.v = a
e.x = j
e.q = j
e.v = a
assert i.v.y.w.y.w.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
j = C("j")
g = D("g")
d = D("d")
n = B("n")
k = B("k")
e = B("e")

a.y = j
i.x = j
i.q = j
i.v = a
j.w = a
g.q = k
d.q = e
n.x = j
n.q = j
n.v = a
k.x = j
k.q = j
k.v = a
e.x = j
e.q = j
e.v = a
assert i.v.y.w.y.w.y.w.y.txt == "j"