class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.x: A = 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.s: D = None
        self.q: B = None
        self.txt = txt

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

g = A("g")
n = B("n")
j = C("j")
e = D("e")
f = B("f")
l = A("l")
b = A("b")

g.p = n
g.z = f
g.x = l
n.v = j
j.s = e
j.q = f
e.y = j
f.v = j
l.p = n
l.z = f
l.x = g
b.p = n
b.z = n
b.x = g
assert l.p.v.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.x: A = 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.s: D = None
        self.q: B = None
        self.txt = txt

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

g = A("g")
n = B("n")
j = C("j")
e = D("e")
f = B("f")
l = A("l")
b = A("b")

g.p = n
g.z = f
g.x = l
n.v = j
j.s = e
j.q = f
e.y = j
f.v = j
l.p = n
l.z = f
l.x = g
b.p = n
b.z = n
b.x = g
assert l.p.v.q.v.txt == "j"