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

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

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

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

g = A("g")
d = B("d")
c = C("c")
j = D("j")
i = B("i")

g.v = d
g.u = j
g.x = c
d.y = j
d.q = i
d.x = c
d.u = c
c.o = g
c.u = g
j.s = c
j.q = c
j.z = g
i.y = j
i.q = d
i.x = c
i.u = c
assert j.z.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: D = None
        self.x: C = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
c = C("c")
j = D("j")
i = B("i")

g.v = d
g.u = j
g.x = c
d.y = j
d.q = i
d.x = c
d.u = c
c.o = g
c.u = g
j.s = c
j.q = c
j.z = g
i.y = j
i.q = d
i.x = c
i.u = c
assert j.z.x.u.txt == "g"