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

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

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

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

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

b.y = k
d.q = i
d.z = i
d.t = e
e.t = b
k.v = a
k.q = b
a.t = b
i.q = d
i.z = d
i.t = e
assert k.q.y.v.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

b.y = k
d.q = i
d.z = i
d.t = e
e.t = b
k.v = a
k.q = b
a.t = b
i.q = d
i.z = d
i.t = e
assert k.q.y.v.t.y.txt == "k"