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

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

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

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

l = A("l")
n = B("n")
c = C("c")
k = D("k")

l.v = k
l.o = n
l.r = c
n.r = l
n.o = k
c.q = n
c.t = n
c.p = n
c.s = k
k.s = c
k.q = c
assert k.q.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: B = None
        self.r: C = None
        self.txt = txt

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

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

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

l = A("l")
n = B("n")
c = C("c")
k = D("k")

l.v = k
l.o = n
l.r = c
n.r = l
n.o = k
c.q = n
c.t = n
c.p = n
c.s = k
k.s = c
k.q = c
assert k.q.s.s.txt == "c"