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

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

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

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

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

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

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

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

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

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

e.z = k
e.x = h
e.q = h
e.o = j
k.q = c
c.w = e
h.x = k
h.o = k
h.v = c
j.z = k
j.x = h
j.q = h
j.o = e
assert c.w.z.q.txt == "c"