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

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

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

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

a = A("a")
k = B("k")
g = C("g")
c = D("c")
l = A("l")

a.o = c
a.r = c
a.t = l
a.w = k
k.v = a
g.q = k
g.x = c
c.r = k
l.o = c
l.r = c
l.t = a
l.w = k
assert g.q.v.r.r.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.t: A = None
        self.w: B = None
        self.r: D = None
        self.txt = txt

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

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

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

a = A("a")
k = B("k")
g = C("g")
c = D("c")
l = A("l")

a.o = c
a.r = c
a.t = l
a.w = k
k.v = a
g.q = k
g.x = c
c.r = k
l.o = c
l.r = c
l.t = a
l.w = k
assert g.q.v.r.r.v.txt == "a"