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

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

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

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

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

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

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

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

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

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

d.v = g
d.x = j
d.u = c
g.v = i
j.y = f
j.x = g
j.z = a
i.z = d
i.q = a
i.r = g
i.w = c
f.v = g
f.x = a
f.u = d
c.v = g
c.x = a
c.u = f
a.y = c
a.x = g
a.z = j
assert i.z.x.y.txt == "f"