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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: D = None
        self.t: B = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
j = C("j")
k = D("k")
d = D("d")
n = C("n")
i = B("i")

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

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

class C:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: D = None
        self.t: B = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
b = B("b")
j = C("j")
k = D("k")
d = D("d")
n = C("n")
i = B("i")

g.w = j
b.z = d
b.x = j
b.y = g
b.q = i
j.r = n
j.v = k
j.t = b
j.y = g
k.z = j
d.z = j
n.r = j
n.v = d
n.t = b
n.y = g
i.z = k
i.x = j
i.y = g
i.q = b
assert d.z.t.x.r.t.x.txt == "j"