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

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

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

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

d = A("d")
n = B("n")
b = C("b")
j = D("j")
m = B("m")
k = C("k")
g = D("g")
h = B("h")
c = B("c")
i = B("i")

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

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

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

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

d = A("d")
n = B("n")
b = C("b")
j = D("j")
m = B("m")
k = C("k")
g = D("g")
h = B("h")
c = B("c")
i = B("i")

d.x = g
d.y = g
n.v = j
n.z = m
b.y = d
b.w = h
j.x = d
m.v = j
m.z = h
k.y = d
k.w = i
g.x = d
h.v = j
h.z = c
c.v = g
c.z = n
i.v = j
i.z = c
assert j.x.y.x.x.x.x.txt == "g"