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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: 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: B = None
        self.z: C = None
        self.v: A = None
        self.p: B = None
        self.txt = txt

l = A("l")
n = B("n")
e = C("e")
c = D("c")
j = A("j")

l.w = n
l.q = c
n.v = e
n.x = l
e.o = j
c.r = n
c.p = n
c.z = e
c.v = l
j.w = n
j.q = c
assert j.q.p.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: 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: B = None
        self.z: C = None
        self.v: A = None
        self.p: B = None
        self.txt = txt

l = A("l")
n = B("n")
e = C("e")
c = D("c")
j = A("j")

l.w = n
l.q = c
n.v = e
n.x = l
e.o = j
c.r = n
c.p = n
c.z = e
c.v = l
j.w = n
j.q = c
assert j.q.p.v.o.txt == "j"