class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: D = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: B = None
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

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

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

a.s = l
a.v = j
a.p = g
n.w = a
n.t = a
n.q = b
n.r = b
l.o = a
j.r = g
j.t = g
j.v = g
j.s = n
g.o = a
b.w = a
b.t = a
b.q = n
b.r = n
assert a.v.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: D = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.q: B = None
        self.r: B = None
        self.t: A = None
        self.txt = txt

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

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

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

a.s = l
a.v = j
a.p = g
n.w = a
n.t = a
n.q = b
n.r = b
l.o = a
j.r = g
j.t = g
j.v = g
j.s = n
g.o = a
b.w = a
b.t = a
b.q = n
b.r = n
assert a.v.v.o.v.txt == "j"