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

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

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

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

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

n.q = e
n.u = g
g.z = e
g.s = e
g.u = n
g.y = n
e.u = n
e.o = g
f.o = g
f.r = g
assert g.u.q.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.u: B = None
        self.txt = txt

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

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

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

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

n.q = e
n.u = g
g.z = e
g.s = e
g.u = n
g.y = n
e.u = n
e.o = g
f.o = g
f.r = g
assert g.u.q.u.q.txt == "e"