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

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

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

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

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

e.v = g
e.w = j
g.r = k
g.u = l
g.o = e
k.r = g
k.o = g
k.z = l
j.o = e
l.r = k
l.u = g
l.o = e
assert g.r.z.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.w: D = None
        self.txt = txt

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

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

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

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

e.v = g
e.w = j
g.r = k
g.u = l
g.o = e
k.r = g
k.o = g
k.z = l
j.o = e
l.r = k
l.u = g
l.o = e
assert g.r.z.o.v.txt == "g"