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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: D = None
        self.t: B = None
        self.u: C = None
        self.txt = txt

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

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

g.z = k
j.p = k
j.q = e
j.x = g
f.p = k
f.t = k
f.w = e
f.u = l
e.p = f
e.q = g
e.o = j
k.p = j
k.q = e
k.x = g
l.p = k
l.t = k
l.w = e
l.u = f
assert e.o.q.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: D = None
        self.t: B = None
        self.u: C = None
        self.txt = txt

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

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

g.z = k
j.p = k
j.q = e
j.x = g
f.p = k
f.t = k
f.w = e
f.u = l
e.p = f
e.q = g
e.o = j
k.p = j
k.q = e
k.x = g
l.p = k
l.t = k
l.w = e
l.u = f
assert e.o.q.q.z.txt == "k"