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

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

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

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

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

n.q = g
n.z = f
j.q = n
j.s = g
j.y = g
j.u = l
d.s = j
g.x = l
l.q = f
l.s = g
l.y = g
l.u = j
f.q = g
f.z = n
assert d.s.q.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: A = None
        self.txt = txt

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

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

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

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

n.q = g
n.z = f
j.q = n
j.s = g
j.y = g
j.u = l
d.s = j
g.x = l
l.q = f
l.s = g
l.y = g
l.u = j
f.q = g
f.z = n
assert d.s.q.q.x.txt == "l"