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

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

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

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

k = A("k")
b = B("b")
a = C("a")
e = D("e")
j = B("j")

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

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

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

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

k = A("k")
b = B("b")
a = C("a")
e = D("e")
j = B("j")

k.q = j
b.v = a
a.x = e
a.s = b
a.v = j
e.x = j
e.t = a
j.v = a
assert e.t.v.v.s.txt == "b"