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

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

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

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

c = A("c")
h = B("h")
d = C("d")
n = D("n")
b = A("b")
i = B("i")
g = D("g")

c.q = g
c.x = d
c.v = b
h.t = d
h.o = n
h.z = i
d.x = c
d.w = b
d.z = g
n.w = b
n.q = c
n.r = g
b.q = g
b.x = d
b.v = c
i.t = d
i.o = n
i.z = h
g.w = c
g.q = c
g.r = n
assert n.q.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.x: C = None
        self.v: A = None
        self.txt = txt

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

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

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

c = A("c")
h = B("h")
d = C("d")
n = D("n")
b = A("b")
i = B("i")
g = D("g")

c.q = g
c.x = d
c.v = b
h.t = d
h.o = n
h.z = i
d.x = c
d.w = b
d.z = g
n.w = b
n.q = c
n.r = g
b.q = g
b.x = d
b.v = c
i.t = d
i.o = n
i.z = h
g.w = c
g.q = c
g.r = n
assert n.q.v.v.txt == "c"