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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

g = A("g")
k = B("k")
j = C("j")
a = D("a")
n = A("n")
h = C("h")
l = D("l")
e = C("e")

g.z = a
g.y = h
g.v = k
g.r = n
k.x = a
j.s = l
a.v = l
a.p = l
a.q = g
a.x = k
n.z = l
n.y = j
n.v = k
n.r = g
h.s = l
l.v = a
l.p = a
l.q = g
l.x = k
e.s = l
assert g.v.x.q.v.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.y: C = None
        self.v: B = None
        self.r: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

g = A("g")
k = B("k")
j = C("j")
a = D("a")
n = A("n")
h = C("h")
l = D("l")
e = C("e")

g.z = a
g.y = h
g.v = k
g.r = n
k.x = a
j.s = l
a.v = l
a.p = l
a.q = g
a.x = k
n.z = l
n.y = j
n.v = k
n.r = g
h.s = l
l.v = a
l.p = a
l.q = g
l.x = k
e.s = l
assert g.v.x.q.v.x.q.txt == "g"