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

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

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

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

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

j.q = i
j.x = c
h.z = e
h.t = c
k.x = i
c.z = k
i.q = j
i.x = c
e.z = h
e.t = c
assert j.q.q.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.x: D = None
        self.txt = txt

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

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

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

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

j.q = i
j.x = c
h.z = e
h.t = c
k.x = i
c.z = k
i.q = j
i.x = c
e.z = h
e.t = c
assert j.q.q.x.z.txt == "k"