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

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

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

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

d = A("d")
i = B("i")
e = C("e")
k = D("k")
j = B("j")
c = C("c")

d.s = j
i.v = e
i.s = j
e.r = c
e.q = d
e.t = d
k.x = d
j.v = c
j.s = i
c.r = e
c.q = d
c.t = d
assert e.q.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
e = C("e")
k = D("k")
j = B("j")
c = C("c")

d.s = j
i.v = e
i.s = j
e.r = c
e.q = d
e.t = d
k.x = d
j.v = c
j.s = i
c.r = e
c.q = d
c.t = d
assert e.q.s.v.txt == "c"