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

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

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

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

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

n.r = f
g.t = l
g.w = l
g.v = f
g.q = f
l.o = n
l.z = n
l.q = g
l.w = f
f.v = g
f.u = g
f.o = n
f.r = l
assert l.o.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

n.r = f
g.t = l
g.w = l
g.v = f
g.q = f
l.o = n
l.z = n
l.q = g
l.w = f
f.v = g
f.u = g
f.o = n
f.r = l
assert l.o.r.r.q.txt == "g"